linkValidator
npm Package | @angular/forms |
---|---|
Module | import { Validator } from '@angular/forms'; |
Source | forms/src/directives/validators.ts |
linkInterface Overview
interface Validator {
validate(c: AbstractControl): ValidationErrors | null
registerOnValidatorChange(fn: () => void)?: void
}
linkDescription
An interface that can be implemented by classes that can act as validators.
linkUsage
@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};
}
}
linkChild Interfaces
linkMembers
validate(c: AbstractControl): ValidationErrors | null