Skip to content

Commit 2b03974

Browse files
committed
fix(NgModel): make sure the pattern validator uses the $validators pipeline
1 parent 154ee61 commit 2b03974

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/ng/directive/input.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -981,16 +981,16 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
981981

982982
if (pattern) {
983983
var validateRegex = function(regexp, value) {
984-
return validate(ctrl, 'pattern', ctrl.$isEmpty(value) || regexp.test(value), value);
984+
return ctrl.$isEmpty(value) || regexp.test(value);
985985
};
986986
match = pattern.match(/^\/(.*)\/([gim]*)$/);
987987
if (match) {
988988
pattern = new RegExp(match[1], match[2]);
989-
patternValidator = function(value) {
989+
ctrl.$validators.pattern = function(value) {
990990
return validateRegex(pattern, value);
991991
};
992992
} else {
993-
patternValidator = function(value) {
993+
ctrl.$validators.pattern = function(value) {
994994
var patternObj = scope.$eval(pattern);
995995

996996
if (!patternObj || !patternObj.test) {
@@ -1001,9 +1001,6 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
10011001
return validateRegex(patternObj, value);
10021002
};
10031003
}
1004-
1005-
ctrl.$formatters.push(patternValidator);
1006-
ctrl.$parsers.push(patternValidator);
10071004
}
10081005

10091006
// min length validator

0 commit comments

Comments
 (0)