Validators
Stable
Class
Class Overview
class Validators { static required(control: AbstractControl) : {[key: string]: boolean} static requiredTrue(control: AbstractControl) : {[key: string]: boolean} static minLength(minLength: number) : ValidatorFn static maxLength(maxLength: number) : ValidatorFn static pattern(pattern: string|RegExp) : ValidatorFn static nullValidator(c: AbstractControl) : {[key: string]: boolean} static compose(validators: ValidatorFn[]) : ValidatorFn static composeAsync(validators: AsyncValidatorFn[]) : AsyncValidatorFn }
Class Description
Provides a set of validators used by form controls.
A validator is a function that processes a FormControl
or collection of controls and returns a map of errors. A null map means that validation has passed.
Example
var loginControl = new FormControl("", Validators.required)
Static Members
required(control: AbstractControl) : {[key: string]: boolean}
Validator that requires controls to have a non-empty value.
requiredTrue(control: AbstractControl) : {[key: string]: boolean}
Validator that requires control value to be true.
minLength(minLength: number) : ValidatorFn
Validator that requires controls to have a value of a minimum length.
maxLength(maxLength: number) : ValidatorFn
Validator that requires controls to have a value of a maximum length.
pattern(pattern: string|RegExp) : ValidatorFn
Validator that requires a control to match a regex to its value.
nullValidator(c: AbstractControl) : {[key: string]: boolean}
No-op validator.
compose(validators: ValidatorFn[]) : ValidatorFn
Compose multiple validators into a single function that returns the union of the individual error maps.
composeAsync(validators: AsyncValidatorFn[]) : AsyncValidatorFn
exported from @angular/forms/index, defined in @angular/forms/src/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/Validators-class.html