...

/

Asynchronous Validation

Asynchronous Validation

Learn how asynchronous validation can provide further capabilities to our forms.

All validation scenarios seen so far require having all the required know-how at the client level, and this is almost always the case. However, in some instances, this knowledge isn’t available on the client side, but only on the backend, where the server business logic can infer the validity of the provided values. Considering our registration form seen in the previous example, we can’t ensure at the client level whether the provided email is unique before letting the user submit the whole form payload and wait for the backend to tell if the given email is available. This wouldn’t provide a good experience for our users. It would be better to give quick feedback targeting the form field of interest.

Use validation rules from the server

Angular helps us once again by providing asynchronous validation, which is exactly what’s needed in these cases.

We can create a custom async validator in the same way we created the previous custom validators, ...