Angular 9 References/ Forms

AsyncValidator interface

This is the documentation for Angular 9.
You can switch to the latest version Angular 10.

An interface implemented by classes that perform asynchronous validation.

Provide a custom async validator directive

The following example implements the AsyncValidator interface to create an async validator directive with a custom error key.

import { of as observableOf } from 'rxjs';

  selector: '[customAsyncValidator]',
  providers: [{provide: NG_ASYNC_VALIDATORS, useExisting: CustomAsyncValidatorDirective, multi:
class CustomAsyncValidatorDirective implements AsyncValidator {
  validate(control: AbstractControl): Observable<ValidationErrors|null> {
    return observableOf({'custom': true});
Links & Tutorials

Interface, extends Validator


validate(control: AbstractControl): Promise<ValidationErrors|null>|Observable<ValidationErrors|null>
Method that performs async validation against the provided control. Returns A promise or observable that resolves a map of validation errors if validation fails, otherwise null.