aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-forms/form-validator.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-forms/form-validator.service.ts')
-rw-r--r--client/src/app/shared/shared-forms/form-validator.service.ts16
1 files changed, 14 insertions, 2 deletions
diff --git a/client/src/app/shared/shared-forms/form-validator.service.ts b/client/src/app/shared/shared-forms/form-validator.service.ts
index 055fbb2d9..0fe50ac9b 100644
--- a/client/src/app/shared/shared-forms/form-validator.service.ts
+++ b/client/src/app/shared/shared-forms/form-validator.service.ts
@@ -1,5 +1,5 @@
1import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
2import { FormBuilder, FormControl, FormGroup, ValidatorFn } from '@angular/forms' 2import { AsyncValidatorFn, FormArray, FormBuilder, FormControl, FormGroup, ValidatorFn } from '@angular/forms'
3import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model' 3import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model'
4import { FormReactiveErrors, FormReactiveValidationMessages } from './form-reactive' 4import { FormReactiveErrors, FormReactiveValidationMessages } from './form-reactive'
5 5
@@ -68,11 +68,23 @@ export class FormValidatorService {
68 68
69 form.addControl( 69 form.addControl(
70 name, 70 name,
71 new FormControl(defaultValue, field?.VALIDATORS as ValidatorFn[]) 71 new FormControl(defaultValue, field?.VALIDATORS as ValidatorFn[], field?.ASYNC_VALIDATORS as AsyncValidatorFn[])
72 ) 72 )
73 } 73 }
74 } 74 }
75 75
76 updateTreeValidity (group: FormGroup | FormArray): void {
77 for (const key of Object.keys(group.controls)) {
78 const abstractControl = group.controls[key] as FormControl
79
80 if (abstractControl instanceof FormGroup || abstractControl instanceof FormArray) {
81 this.updateTreeValidity(abstractControl)
82 } else {
83 abstractControl.updateValueAndValidity({ emitEvent: false })
84 }
85 }
86 }
87
76 private isRecursiveField (field: any) { 88 private isRecursiveField (field: any) {
77 return field && typeof field === 'object' && !field.MESSAGES && !field.VALIDATORS 89 return field && typeof field === 'object' && !field.MESSAGES && !field.VALIDATORS
78 } 90 }