()
| 21256 | |
| 21257 | |
| 21258 | var patternDirective = function() { |
| 21259 | return { |
| 21260 | restrict: 'A', |
| 21261 | require: '?ngModel', |
| 21262 | link: function(scope, elm, attr, ctrl) { |
| 21263 | if (!ctrl) return; |
| 21264 | |
| 21265 | var regexp, patternExp = attr.ngPattern || attr.pattern; |
| 21266 | attr.$observe('pattern', function(regex) { |
| 21267 | if (isString(regex) && regex.length > 0) { |
| 21268 | regex = new RegExp('^' + regex + '$'); |
| 21269 | } |
| 21270 | |
| 21271 | if (regex && !regex.test) { |
| 21272 | throw minErr('ngPattern')('noregexp', |
| 21273 | 'Expected {0} to be a RegExp but was {1}. Element: {2}', patternExp, |
| 21274 | regex, startingTag(elm)); |
| 21275 | } |
| 21276 | |
| 21277 | regexp = regex || undefined; |
| 21278 | ctrl.$validate(); |
| 21279 | }); |
| 21280 | |
| 21281 | ctrl.$validators.pattern = function(value) { |
| 21282 | return ctrl.$isEmpty(value) || isUndefined(regexp) || regexp.test(value); |
| 21283 | }; |
| 21284 | } |
| 21285 | }; |
| 21286 | }; |
| 21287 | |
| 21288 | |
| 21289 | var maxlengthDirective = function() { |
nothing calls this directly
no test coverage detected