linkCheckboxRequiredValidator
npm Package | @angular/forms |
---|---|
Module | import { CheckboxRequiredValidator } from '@angular/forms'; |
Source | forms/src/directives/validators.ts |
linkOverview
@Directive({
selector: 'input[type=checkbox][required][formControlName],input[type=checkbox][required][formControl],input[type=checkbox][required][ngModel]',
providers: [CHECKBOX_REQUIRED_VALIDATOR],
host: { '[attr.required]': 'required ? "" : null' }
})
class CheckboxRequiredValidator extends RequiredValidator {
validate(c: AbstractControl): ValidationErrors | null
// inherited from forms/RequiredValidator
required: boolean | string
validate(c: AbstractControl): ValidationErrors | null
registerOnValidatorChange(fn: () => void): void
}
linkSelectors
input[type=checkbox][required][formControlName]
input[type=checkbox][required][formControl]
input[type=checkbox][required][ngModel]
linkDescription
A Directive that adds the required
validator to checkbox controls marked with the
required
attribute, via the NG_VALIDATORS
binding.
linkExample
<input type="checkbox" name="active" ngModel required>
linkMembers
validate(c: AbstractControl): ValidationErrors | null