Skip to content

Commit d2cd990

Browse files
committed
private validators fn
1 parent d225105 commit d2cd990

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/ng/directive/input.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1758,12 +1758,11 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
17581758
* @description
17591759
* Runs each of the registered validations set on the $validators object.
17601760
*/
1761-
this.$validate = function(modelValue, viewValue) {
1762-
if(arguments.length === 0) {
1763-
modelValue = ctrl.$modelValue;
1764-
viewValue = ctrl.$viewValue;
1765-
}
1761+
this.$validate = function() {
1762+
this.$$runValidators(ctrl.$modelValue, ctrl.$viewValue);
1763+
};
17661764

1765+
this.$$runValidators = function(modelValue, viewValue) {
17671766
forEach(ctrl.$validators, function(fn, name) {
17681767
ctrl.$setValidity(name, fn(modelValue, viewValue));
17691768
});
@@ -1805,7 +1804,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
18051804
if (ctrl.$modelValue !== modelValue &&
18061805
(isUndefined(ctrl.$$invalidModelValue) || ctrl.$$invalidModelValue != modelValue)) {
18071806

1808-
ctrl.$validate(modelValue, viewValue);
1807+
ctrl.$$runValidators(modelValue, viewValue);
18091808
ctrl.$modelValue = ctrl.$valid ? modelValue : undefined;
18101809
ctrl.$$invalidModelValue = ctrl.$valid ? undefined : modelValue;
18111810

@@ -1897,7 +1896,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
18971896
viewValue = formatters[idx](viewValue);
18981897
}
18991898

1900-
ctrl.$validate(modelValue, viewValue);
1899+
ctrl.$$runValidators(modelValue, viewValue);
19011900
ctrl.$modelValue = ctrl.$valid ? modelValue : undefined;
19021901
ctrl.$$invalidModelValue = ctrl.$valid ? undefined : modelValue;
19031902

0 commit comments

Comments
 (0)