()
| 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) { |
no test coverage detected