CheckboxRequiredValidator

directive

npm Package @angular/forms
Module import { CheckboxRequiredValidator } from '@angular/forms';
Source forms/src/directives/validators.ts

Overview

@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
}

Selectors

input[type=checkbox][required][formControlName] input[type=checkbox][required][formControl] input[type=checkbox][required][ngModel]

Description

A Directive that adds the required validator to checkbox controls marked with the required attribute, via the NG_VALIDATORS binding.

Example

<input type="checkbox" name="active" ngModel required>

Members

validate(c: AbstractControl): ValidationErrors|null

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v4.angular.io/api/forms/CheckboxRequiredValidator