GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Docs
  • Tutorials
  • Playground
  • Reference
  • code
  • Creating asynchronous validators
  • ValidationErrors

This view

  • Original page
  • New address

GeezerVison is showing angular.dev — AsyncValidator • Angular

API

    
      interface AsyncValidator extends Validator {}
    
    

Method that performs async validation against the provided control.

@paramcontrolAbstractControl<any, any, any>

The control to validate against.

@returnsPromise<ValidationErrors | null> | Observable<ValidationErrors | null>

A promise or observable that resolves a map of validation errors if validation fails, otherwise null.

Registers a callback function to call when the validator inputs change.

@paramfn() => void

The callback function

@returnsvoid

Usage Notes

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 } from 'rxjs';

@Directive({
  selector: '[customAsyncValidator]',
  providers: [{provide: NG_ASYNC_VALIDATORS, useExisting: CustomAsyncValidatorDirective, multi:
true}]
})
class CustomAsyncValidatorDirective implements AsyncValidator {
  validate(control: AbstractControl): Observable<ValidationErrors|null> {
    return of({'custom': true});
  }
}
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.