MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / patternDirective

Function patternDirective

lib/test/angular/1.4.3/angular.js:28276–28304  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28274
28275
28276var patternDirective = function() {
28277 return {
28278 restrict: 'A',
28279 require: '?ngModel',
28280 link: function(scope, elm, attr, ctrl) {
28281 if (!ctrl) return;
28282
28283 var regexp, patternExp = attr.ngPattern || attr.pattern;
28284 attr.$observe('pattern', function(regex) {
28285 if (isString(regex) && regex.length > 0) {
28286 regex = new RegExp('^' + regex + '$');
28287 }
28288
28289 if (regex && !regex.test) {
28290 throw minErr('ngPattern')('noregexp',
28291 'Expected {0} to be a RegExp but was {1}. Element: {2}', patternExp,
28292 regex, startingTag(elm));
28293 }
28294
28295 regexp = regex || undefined;
28296 ctrl.$validate();
28297 });
28298
28299 ctrl.$validators.pattern = function(value) {
28300 return ctrl.$isEmpty(value) || isUndefined(regexp) || regexp.test(value);
28301 };
28302 }
28303 };
28304};
28305
28306
28307var 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