()
| 23322 | } |
| 23323 | |
| 23324 | function processAsyncValidators() { |
| 23325 | var validatorPromises = []; |
| 23326 | var allValid = true; |
| 23327 | forEach(ctrl.$asyncValidators, function(validator, name) { |
| 23328 | var promise = validator(modelValue, viewValue); |
| 23329 | if (!isPromiseLike(promise)) { |
| 23330 | throw ngModelMinErr("$asyncValidators", |
| 23331 | "Expected asynchronous validator to return a promise but got '{0}' instead.", promise); |
| 23332 | } |
| 23333 | setValidity(name, undefined); |
| 23334 | validatorPromises.push(promise.then(function() { |
| 23335 | setValidity(name, true); |
| 23336 | }, function(error) { |
| 23337 | allValid = false; |
| 23338 | setValidity(name, false); |
| 23339 | })); |
| 23340 | }); |
| 23341 | if (!validatorPromises.length) { |
| 23342 | validationDone(true); |
| 23343 | } else { |
| 23344 | $q.all(validatorPromises).then(function() { |
| 23345 | validationDone(allValid); |
| 23346 | }, noop); |
| 23347 | } |
| 23348 | } |
| 23349 | |
| 23350 | function setValidity(name, isValid) { |
| 23351 | if (localValidationRunId === currentValidationRunId) { |
no test coverage detected