()
| 26360 | |
| 26361 | |
| 26362 | var patternDirective = function() { |
| 26363 | return { |
| 26364 | restrict: 'A', |
| 26365 | require: '?ngModel', |
| 26366 | link: function(scope, elm, attr, ctrl) { |
| 26367 | if (!ctrl) return; |
| 26368 | |
| 26369 | var regexp, patternExp = attr.ngPattern || attr.pattern; |
| 26370 | attr.$observe('pattern', function(regex) { |
| 26371 | if (isString(regex) && regex.length > 0) { |
| 26372 | regex = new RegExp('^' + regex + '$'); |
| 26373 | } |
| 26374 | |
| 26375 | if (regex && !regex.test) { |
| 26376 | throw minErr('ngPattern')('noregexp', |
| 26377 | 'Expected {0} to be a RegExp but was {1}. Element: {2}', patternExp, |
| 26378 | regex, startingTag(elm)); |
| 26379 | } |
| 26380 | |
| 26381 | regexp = regex || undefined; |
| 26382 | ctrl.$validate(); |
| 26383 | }); |
| 26384 | |
| 26385 | ctrl.$validators.pattern = function(modelValue, viewValue) { |
| 26386 | // HTML5 pattern constraint validates the input value, so we validate the viewValue |
| 26387 | return ctrl.$isEmpty(viewValue) || isUndefined(regexp) || regexp.test(viewValue); |
| 26388 | }; |
| 26389 | } |
| 26390 | }; |
| 26391 | }; |
| 26392 | |
| 26393 | |
| 26394 | var maxlengthDirective = function() { |
nothing calls this directly
no test coverage detected