Skip to content

Commit 76e5408

Browse files
committed
refactor(NgModel): make sure the pattern validator uses the $validators pipeline
1 parent 9385017 commit 76e5408

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
@@ -990,16 +990,16 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
990990

991991
if (pattern) {
992992
var validateRegex = function(regexp, value) {
993-
return validate(ctrl, 'pattern', ctrl.$isEmpty(value) || regexp.test(value), value);
993+
return ctrl.$isEmpty(value) || regexp.test(value);
994994
};
995995
match = pattern.match(/^\/(.*)\/([gim]*)$/);
996996
if (match) {
997997
pattern = new RegExp(match[1], match[2]);
998-
patternValidator = function(value) {
998+
ctrl.$validators.pattern = function(value) {
999999
return validateRegex(pattern, value);
10001000
};
10011001
} else {
1002-
patternValidator = function(value) {
1002+
ctrl.$validators.pattern = function(value) {
10031003
var patternObj = scope.$eval(pattern);
10041004

10051005
if (!patternObj || !patternObj.test) {
@@ -1010,9 +1010,6 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
10101010
return validateRegex(patternObj, value);
10111011
};
10121012
}
1013-
1014-
ctrl.$formatters.push(patternValidator);
1015-
ctrl.$parsers.push(patternValidator);
10161013
}
10171014

10181015
// min length validator

0 commit comments

Comments
 (0)