Async Validator

A form rule that checks a value asynchronously, such as with a server call.

What is Async Validator?

An async validator checks a value using something slow, like asking the server whether a username is taken. It returns an Observable or Promise.

usernameFree: AsyncValidatorFn = control =>
  this.http.get<boolean>(`/api/users/exists/${control.value}`)
    .pipe(map(taken => taken ? { taken: true } : null));

Level: Freelancer · More Angular terms at this level

Updated