PatternValidator
directive
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.
NgModules
Selectors
[pattern][formControlName][pattern][formControl][pattern][ngModel]
Properties
| Property | Description |
|---|---|
@Input()pattern: string | RegExp |
Description
Example
<input [name]="fullName" pattern="[a-zA-Z ]*" ngModel>
Methods
| ngOnChanges() | ||
|---|---|---|
|
| changes | Type: |
Returns
void
| validate() | ||
|---|---|---|
|
| control | Type: |
Returns
ValidationErrors | null
| registerOnValidatorChange() | ||
|---|---|---|
|
| fn | Type: |
Returns
void
© 2010–2019 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v6.angular.io/api/forms/PatternValidator