On this page
Validator
interface
npm Package | @angular/forms |
---|---|
Module | import { Validator } from '@angular/forms'; |
Source | forms/src/directives/validators.ts |
Interface Overview
interface Validator {
validate(c: AbstractControl): ValidationErrors | null
registerOnValidatorChange(fn: () => void)?: void
}
Description
An interface that can be implemented by classes that can act as validators.
Usage
@Directive({
selector: '[custom-validator]',
providers: [{provide: NG_VALIDATORS, useExisting: CustomValidatorDirective, multi: true}]
})
class CustomValidatorDirective implements Validator {
validate(c: Control): {[key: string]: any} {
return {"custom": true};
}
}
Child Interfaces
AsyncValidator
Members
validate(c: AbstractControl): ValidationErrors | null
registerOnValidatorChange(fn: () => void)?: void
© 2010–2018 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v5.angular.io/api/forms/Validator