W3cubDocs

/Angular 2 TypeScript

RequiredValidator

Stable Directive

Class Overview

class RequiredValidator implements Validator {
  required : boolean
  validate(c: AbstractControl) : {[key: string]: any}
  registerOnValidatorChange(fn: () => void) : void
}

Selectors

:not([type=checkbox])[required][formControlName]

:not([type=checkbox])[required][formControl]

:not([type=checkbox])[required][ngModel]

Class 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>

Class Details

required : boolean
validate(c: AbstractControl) : {[key: string]: any}
registerOnValidatorChange(fn: () => void) : void

exported from @angular/forms/index, defined in @angular/forms/src/directives/validators.ts

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v2.angular.io/docs/ts/latest/api/forms/index/RequiredValidator-directive.html