On this page
RequiredValidator
directive
npm Package | @angular/forms |
---|---|
Module | import { RequiredValidator } from '@angular/forms'; |
Source | forms/src/directives/validators.ts |
Overview
@Directive({
selector: ':not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]',
providers: [REQUIRED_VALIDATOR],
host: { '[attr.required]': 'required ? "" : null' }
})
class RequiredValidator implements Validator {
required: boolean|string
validate(c: AbstractControl): ValidationErrors|null
registerOnValidatorChange(fn: () => void): void
}
Selectors
:not([type=checkbox])[required][formControlName] :not([type=checkbox])[required][formControl] :not([type=checkbox])[required][ngModel]
Inputs
required
bound to RequiredValidator.required
Description
A Directive that adds the required
validator to any controls marked with the required
attribute, via the NG_VALIDATORS
binding.
Example
<input name="fullName" ngModel required>
Members
required: boolean|string
validate(c: AbstractControl): ValidationErrors|null
registerOnValidatorChange(fn: () => void): void
© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v4.angular.io/api/forms/RequiredValidator