DEV Community

Discussion on: Building scalable robusts and type safe forms with Angular

 
andrewtraub profile image
AndrewTraub

Thanks. Is there any way to add a custom validation for the entire group? Normally, I'd do so like this:

createFormGroup() {
this.myForm = this.fb.group({
mobile : new FormControl(''),
homePhone : new FormControl('')
// our custom validator
}, { validator: this.atLeastOnePhoneRequired});
}

but in the form using ngx-sub-form I'm using code like this:
protected getFormControls(): Controls {
return {
mobile : new FormControl(null),
homePhone : new FormControl(null)
};
}

Thread Thread
 
maxime1992 profile image
Maxime

Yes, there's definitely a way to do that.

Search getFormGroupControlOptions on the README :)