import { FormArray , FormGroup , ValidatorFn , AbstractControl } from "@angular/forms" ; export function customChangeValidator ( customValidation ) { return ( control ) : { [ key ] : any ; } => { for ( let prop of customValidation . requiredProps ) { let currentControl ; if ( customValidation . nestedProperty ) { let formControl = control . root . get ( [ customValidation . nestedProperty ] ) ; if ( formControl instanceof FormArray ) { let formGroup = < FormGroup > formControl . controls [ 0 ] ; currentControl = formGroup . get ( [ prop ] ) ; } } if ( currentControl ) { setTimeout ( ( ) => currentControl . updateValueAndValidity ( ) , 300 ) ; } } return null ; } ; }