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

Function patternDirective

test/angular/1.3/angular.js:26362–26391  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26360
26361
26362var 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
26394var 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