diff --git a/src/validators/edition-group.ts b/src/validators/edition-group.ts index 6785560e..2f5db9d8 100644 --- a/src/validators/edition-group.ts +++ b/src/validators/edition-group.ts @@ -29,6 +29,7 @@ import { } from './common'; import type {IdentifierTypeWithIdT} from '../types/identifiers'; +import {Iterable} from 'immutable'; import _ from 'lodash'; import {isIterable} from '../util'; @@ -52,8 +53,13 @@ export function validateEditionGroup( validateAuthorCreditSectionMerge(get(formData, 'authorCredit', {})); } else if (!authorCreditEnable) { - const emptyAuthorCredit = isIterable(formData) ? formData.get('authorCreditEditor')?.size === 0 : - _.size(get(formData, 'authorCreditEditor', {})) === 0; + let emptyAuthorCredit:boolean; + if (isIterable(formData)) { + emptyAuthorCredit = (formData.get('authorCreditEditor') as Iterable)?.size === 0; + } + else { + emptyAuthorCredit = _.size(get(formData, 'authorCreditEditor', {})) === 0; + } if (!emptyAuthorCredit) { throw new ValidationError('Disabled author credit has to be empty', 'authorCreditEditor'); } diff --git a/src/validators/edition.ts b/src/validators/edition.ts index 8ad166f4..07df52dc 100644 --- a/src/validators/edition.ts +++ b/src/validators/edition.ts @@ -33,6 +33,7 @@ import {ValidationError, get, validateDate, validatePositiveInteger, validateUUI import {convertMapToObject, isIterable} from '../util'; import {IdentifierTypeWithIdT} from '../types/identifiers'; +import {Iterable} from 'immutable'; import _ from 'lodash'; @@ -127,8 +128,13 @@ export function validateEdition( validateAuthorCreditSectionMerge(get(formData, 'authorCredit', {})); } else if (!authorCreditEnable) { - const emptyAuthorCredit = isIterable(formData) ? formData.get('authorCreditEditor')?.size === 0 : - _.size(get(formData, 'authorCreditEditor', {})) === 0; + let emptyAuthorCredit:boolean; + if (isIterable(formData)) { + emptyAuthorCredit = (formData.get('authorCreditEditor') as Iterable)?.size === 0; + } + else { + emptyAuthorCredit = _.size(get(formData, 'authorCreditEditor', {})) === 0; + } if (!emptyAuthorCredit) { throw new ValidationError('Disabled author credit has to be empty', 'authorCreditEditor'); }