MCPcopy Create free account
hub / github.com/EricSimons/ionic-course / patternDirective

Function patternDirective

code/songhop/www/lib/angular/angular.js:21258–21286  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21256
21257
21258var 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
21289var maxlengthDirective = function() {

Callers

nothing calls this directly

Calls 4

isStringFunction · 0.70
minErrFunction · 0.70
startingTagFunction · 0.70
isUndefinedFunction · 0.70

Tested by

no test coverage detected