Creating and using a custom asynchronous validator with Promises
A standard validator operates under the assumption that the validity of a certain input can be calculated in a short amount of time that the application can wait to get over with before it continues further. What's more, Angular will run this validation every time the validator is invoked, which might be quite often if form validation is bound to rapid-fire events such as keypresses.
Therefore, it makes good sense that a construct exists that will allow you to smoothly handle the validation procedures that take an arbitrary amount of time to execute or procedures that might not return at all. For this, Angular offers
async Validator, which is fully compatible with