have a simple dynamically generated form
this.submitForm = this._fb.group({
'tournamentid': new FormControl(null),
'participants': this._fb.array([ ], [CustomValidators.uniqueBy('nric'), this.averageAgeValidator(45)])
});
Add Players event will dynamically add below code
addPlayers(): FormGroup {
return this._fb.group({
'nric': new FormControl(null, [Validators.required]),
'nricname': new FormControl(null, Validators.required),
'dob': new FormControl(null, Validators.required),
});
}
I want to validate if average DOB of all the dynamically added form fields is 45 years. have function to calculate age, and i have a date component to get dates. need to know how to loop through the formarrays and get only the dob fields and get average of it.
how should my averageAgeValidator function work to flag error when the average age of all the added players is 45 years. please suggest
<input type="number" />type thing ?