()
| 26223 | } |
| 26224 | |
| 26225 | function processAsyncValidators() { |
| 26226 | var validatorPromises = []; |
| 26227 | var allValid = true; |
| 26228 | forEach(ctrl.$asyncValidators, function(validator, name) { |
| 26229 | var promise = validator(modelValue, viewValue); |
| 26230 | if (!isPromiseLike(promise)) { |
| 26231 | throw ngModelMinErr('nopromise', |
| 26232 | "Expected asynchronous validator to return a promise but got '{0}' instead.", promise); |
| 26233 | } |
| 26234 | setValidity(name, undefined); |
| 26235 | validatorPromises.push(promise.then(function() { |
| 26236 | setValidity(name, true); |
| 26237 | }, function(error) { |
| 26238 | allValid = false; |
| 26239 | setValidity(name, false); |
| 26240 | })); |
| 26241 | }); |
| 26242 | if (!validatorPromises.length) { |
| 26243 | validationDone(true); |
| 26244 | } else { |
| 26245 | $q.all(validatorPromises).then(function() { |
| 26246 | validationDone(allValid); |
| 26247 | }, noop); |
| 26248 | } |
| 26249 | } |
| 26250 | |
| 26251 | function setValidity(name, isValid) { |
| 26252 | if (localValidationRunId === currentValidationRunId) { |
no test coverage detected