Angular (2024)

Class Overview

class Validators {

staticrequired(control: AbstractControl) : {[key: string]: boolean}
staticrequiredTrue(control: AbstractControl) : {[key: string]: boolean}
staticminLength(minLength: number) : ValidatorFn
staticmaxLength(maxLength: number) : ValidatorFn
staticpattern(pattern: string|RegExp) : 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 ofcontrols 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 unionof the individual error maps.

composeAsync(validators: AsyncValidatorFn[]) : AsyncValidatorFn

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

Angular (2024)
Top Articles
Latest Posts
Article information

Author: Ray Christiansen

Last Updated:

Views: 5951

Rating: 4.9 / 5 (69 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Ray Christiansen

Birthday: 1998-05-04

Address: Apt. 814 34339 Sauer Islands, Hirtheville, GA 02446-8771

Phone: +337636892828

Job: Lead Hospitality Designer

Hobby: Urban exploration, Tai chi, Lockpicking, Fashion, Gunsmithing, Pottery, Geocaching

Introduction: My name is Ray Christiansen, I am a fair, good, cute, gentle, vast, glamorous, excited person who loves writing and wants to share my knowledge and understanding with you.