diff --git a/src/frontend/app/indexation/indexing-form/indexing-form.component.ts b/src/frontend/app/indexation/indexing-form/indexing-form.component.ts index dd79d09d690345acfbf1356f13d0b7a8f18e67bf..7fe3cb8b9ef22625e3949865050131f9b48f5cb3 100755 --- a/src/frontend/app/indexation/indexing-form/indexing-form.component.ts +++ b/src/frontend/app/indexation/indexing-form/indexing-form.component.ts @@ -888,6 +888,8 @@ export class IndexingFormComponent implements OnInit { if (field.mandatory) { valArr.push(Validators.required); valArr.push(this.requireDestValidator({ 'isDest': '' })); + } else { + valArr.push(this.requireDestValidatorOrEmpty({ 'isDest': '' })); } this.arrFormControl['diffusionList'] = new FormControl({ value: null, disabled: false }); @@ -908,6 +910,15 @@ export class IndexingFormComponent implements OnInit { }; } + requireDestValidatorOrEmpty(error: ValidationErrors): ValidatorFn { + return (control: AbstractControl): { [key: string]: any } => { + if (!control.value) { + return null; + } + return control.value.filter((item: any) => item.mode === 'dest').length > 0 || this.functions.empty(this.arrFormControl['destination'].value) ? null : error; + }; + } + regexValidator(regex: RegExp, error: ValidationErrors): ValidatorFn { return (control: AbstractControl): { [key: string]: any } => { if (!control.value) {