MCPcopy Create free account
hub / github.com/EricSimons/ionic-course / processAsyncValidators

Function processAsyncValidators

code/songhop/www/lib/angular/angular.js:20698–20722  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20696 }
20697
20698 function processAsyncValidators() {
20699 var validatorPromises = [];
20700 var allValid = true;
20701 forEach(ctrl.$asyncValidators, function(validator, name) {
20702 var promise = validator(modelValue, viewValue);
20703 if (!isPromiseLike(promise)) {
20704 throw $ngModelMinErr("$asyncValidators",
20705 "Expected asynchronous validator to return a promise but got '{0}' instead.", promise);
20706 }
20707 setValidity(name, undefined);
20708 validatorPromises.push(promise.then(function() {
20709 setValidity(name, true);
20710 }, function(error) {
20711 allValid = false;
20712 setValidity(name, false);
20713 }));
20714 });
20715 if (!validatorPromises.length) {
20716 validationDone(true);
20717 } else {
20718 $q.all(validatorPromises).then(function() {
20719 validationDone(allValid);
20720 }, noop);
20721 }
20722 }
20723
20724 function setValidity(name, isValid) {
20725 if (localValidationRunId === currentValidationRunId) {

Callers 1

angular.jsFile · 0.70

Calls 4

forEachFunction · 0.70
isPromiseLikeFunction · 0.70
setValidityFunction · 0.70
validationDoneFunction · 0.70

Tested by

no test coverage detected