const
An InjectionToken
for registering additional asynchronous validators used with AbstractControl
s.
const NG_ASYNC_VALIDATORS: InjectionToken<(Function | Validator)[]>;
The following example implements the AsyncValidator
interface to create an async validator directive with a custom error key.
@Directive({ selector: '[customAsyncValidator]', providers: [{provide: NG_ASYNC_VALIDATORS, useExisting: CustomAsyncValidatorDirective, multi: true}] }) class CustomAsyncValidatorDirective implements AsyncValidator { validate(control: AbstractControl): Promise<ValidationErrors|null> { return Promise.resolve({'custom': true}); } }
© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/forms/NG_ASYNC_VALIDATORS