linkPatternValidator
npm Package | @angular/forms |
---|---|
Module | import { PatternValidator } from '@angular/forms'; |
Source | forms/src/directives/validators.ts |
linkOverview
@Directive({
selector: '[pattern][formControlName],[pattern][formControl],[pattern][ngModel]',
providers: [PATTERN_VALIDATOR],
host: { '[attr.pattern]': 'pattern ? pattern : null' }
})
class PatternValidator implements Validator, OnChanges {
pattern: string | RegExp
ngOnChanges(changes: SimpleChanges): void
validate(c: AbstractControl): ValidationErrors | null
registerOnValidatorChange(fn: () => void): void
}
linkSelectors
[pattern][formControlName]
[pattern][formControl]
[pattern][ngModel]
linkInputs
pattern
bound to PatternValidator.pattern
linkDescription
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.
linkExample
<input [name]="fullName" pattern="[a-zA-Z ]*" ngModel>
linkMembers
pattern: string | RegExp
ngOnChanges(changes: SimpleChanges): void
validate(c: AbstractControl): ValidationErrors | null