fix(NgModel): make sure the pattern validator uses the $validators pipeline

This commit is contained in:
Matias Niemelä
2014-04-30 21:01:47 -04:00
parent e53554a0e2
commit e63d4253d0

View File

@@ -996,12 +996,9 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
regexp = regex || undefined;
});
var patternValidator = function(value) {
return validate(ctrl, 'pattern', ctrl.$isEmpty(value) || isUndefined(regexp) || regexp.test(value), value);
ctrl.$validators.pattern = function(value) {
return ctrl.$isEmpty(value) || isUndefined(regexp) || regexp.test(value);
};
ctrl.$formatters.push(patternValidator);
ctrl.$parsers.push(patternValidator);
}
// min length validator