Validators

Stable Class

Class Overview

class Validators {
  staticrequired(control: AbstractControl) : {[key: string]: boolean}
  staticminLength(minLength: number) : ValidatorFn
  staticmaxLength(maxLength: number) : ValidatorFn
  staticpattern(pattern: string) : ValidatorFn
  staticnullValidator(c: AbstractControl) : {[key: string]: boolean}
  staticcompose(validators: ValidatorFn[]) : ValidatorFn
  staticcomposeAsync(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.

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) : 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

doc_Angular
2016-10-06 09:47:11
Comments
Leave a Comment

Please login to continue.