From 945b8147a0dc73b9671126997fb09cde197fae85 Mon Sep 17 00:00:00 2001 From: amontenegro Date: Thu, 30 Nov 2023 15:48:54 -0600 Subject: [PATCH] Still not working --- .../work-form/work-form/work-form.component.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app/record/components/work-form/work-form/work-form.component.ts b/src/app/record/components/work-form/work-form/work-form.component.ts index 1f82019b78..bd71f07d6d 100644 --- a/src/app/record/components/work-form/work-form/work-form.component.ts +++ b/src/app/record/components/work-form/work-form/work-form.component.ts @@ -52,7 +52,7 @@ import { SnackbarService } from 'src/app/cdk/snackbar/snackbar.service' import { WorkIdentifiers } from 'src/app/shared/validators/work-identifiers/work-identifiers.validator' import { workCitationValidator } from 'src/app/shared/validators/citation/work-citation.validator' import { translatedTitleValidator } from 'src/app/shared/validators/translated-title/translated-title.validator' -import { merge, Subject } from 'rxjs' +import { merge, Subject, of } from 'rxjs' import { RecordService } from 'src/app/core/record/record.service' @Component({ @@ -266,7 +266,17 @@ export class WorkFormComponent implements OnInit { formGroup: UntypedFormGroup, externalIdentifierType: string ): AsyncValidatorFn { - return (control: AbstractControl) => { + + if(externalIdentifierType === 'isbn') { + return (control: AbstractControl) => { + of(undefined) + .pipe(map( () => { + if(!(formGroup.controls.externalIdentifierId.value?.lenght == 10 || formGroup.controls.externalIdentifierId.value == 13)) {return { validFormat: true, }} + } + )) + } + } else { + return (control: AbstractControl) => { return this._workService .validateWorkIdTypes(externalIdentifierType, control.value) .pipe( @@ -313,6 +323,7 @@ export class WorkFormComponent implements OnInit { }) ) } + } } private checkWorkIdentifiersChanges(