PatternValidator

Stable Directive

Class Overview

class PatternValidator {
  pattern : string
  ngOnChanges(changes: SimpleChanges)
  validate(c: AbstractControl) : {[key: string]: any}
  registerOnValidatorChange(fn: () => void)
}

Selectors

[pattern][formControlName]

[pattern][formControl]

[pattern][ngModel]

Class Description

A Directive that adds the pattern validator to any controls marked with the pattern attribute, via the NG_VALIDATORS binding. Uses attribute value as the regex to validate Control value against. Follows pattern attribute semantics; i.e. regex must match entire Control value.

Example

<input [name]="fullName" pattern="[a-zA-Z ]*" ngModel>

Class Details

pattern : string
ngOnChanges(changes: SimpleChanges)
validate(c: AbstractControl) : {[key: string]: any}
registerOnValidatorChange(fn: () => void)

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

doc_Angular
2016-10-06 09:46:49
Comments
Leave a Comment

Please login to continue.