Validator
interface
An interface implemented by classes that perform synchronous validation.
validate
ValidationErrors | null
Method that performs synchronous validation against the provided control.
@returns
ValidationErrors | null
registerOnValidatorChange
void
Registers a callback function to call when the validator inputs change.
@paramfn
() => void
The callback function
@returns
void
Usage Notes
Provide a custom validator
The following example implements the Validator
interface to create a
validator directive with a custom error key.
@Directive({ selector: '[customValidator]', providers: [{provide: NG_VALIDATORS, useExisting: CustomValidatorDirective, multi: true}]})class CustomValidatorDirective implements Validator { validate(control: AbstractControl): ValidationErrors|null { return {'custom': true}; }}
Jump to details