What are async validators and when do you need one?

Angular forms · Freshers and experienced

Model answer

An async validator returns an Observable or Promise, and is used for checks that need the server, such as "is this username taken?". While it runs the control status is pending.

To avoid a request on every key press, debounce with a timer and switchMap, or update only on blur (updateOn: 'blur'). Also handle errors: if the check fails because of the network, do not block the user forever.

Learn this topic

Angular Tutorial: Beginner to Advanced .

Sign in to add your own answer.

More questions