Open drkhannah opened 4 years ago
as far as i know it needs a custom-validator on the group. in this validator can then be iterated over the controls of the group.
export function myCustomValidator(control: AbstractControl): ValidationErrors | null {
let countChecked = 0;
Object.keys(group.controls).forEach((key) => {
const c: AbstractControl = group.get(key);
if (c.value === true) {
countChecked++;
}
});
const hasError = countChecked < 1;
return hasError ? {myCustomValidator: true} : null;
}
I'm submitting a
I'm using
Description
Hello
Thank you for this great library
I have noticed that when i add validators to a CHECKBOX_GROUP they don't work. I want to require at least one checkbox to be checked in a checkbox group.
I have tried using validators and groupValidators, but the formgroup is always valid even after i check and uncheck all checkboxes, and no error message shows if no checkboxes are checked