()
| 28685 | |
| 28686 | |
| 28687 | var patternDirective = function() { |
| 28688 | return { |
| 28689 | restrict: 'A', |
| 28690 | require: '?ngModel', |
| 28691 | link: function(scope, elm, attr, ctrl) { |
| 28692 | if (!ctrl) return; |
| 28693 | |
| 28694 | var regexp, patternExp = attr.ngPattern || attr.pattern; |
| 28695 | attr.$observe('pattern', function(regex) { |
| 28696 | if (isString(regex) && regex.length > 0) { |
| 28697 | regex = new RegExp('^' + regex + '$'); |
| 28698 | } |
| 28699 | |
| 28700 | if (regex && !regex.test) { |
| 28701 | throw minErr('ngPattern')('noregexp', |
| 28702 | 'Expected {0} to be a RegExp but was {1}. Element: {2}', patternExp, |
| 28703 | regex, startingTag(elm)); |
| 28704 | } |
| 28705 | |
| 28706 | regexp = regex || undefined; |
| 28707 | ctrl.$validate(); |
| 28708 | }); |
| 28709 | |
| 28710 | ctrl.$validators.pattern = function(modelValue, viewValue) { |
| 28711 | // HTML5 pattern constraint validates the input value, so we validate the viewValue |
| 28712 | return ctrl.$isEmpty(viewValue) || isUndefined(regexp) || regexp.test(viewValue); |
| 28713 | }; |
| 28714 | } |
| 28715 | }; |
| 28716 | }; |
| 28717 | |
| 28718 | |
| 28719 | var maxlengthDirective = function() { |
nothing calls this directly
no test coverage detected