MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / maxlengthDirective

Function maxlengthDirective

web/static/bower_components/angular/angular.js:28719–28737  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28717
28718
28719var maxlengthDirective = function() {
28720 return {
28721 restrict: 'A',
28722 require: '?ngModel',
28723 link: function(scope, elm, attr, ctrl) {
28724 if (!ctrl) return;
28725
28726 var maxlength = -1;
28727 attr.$observe('maxlength', function(value) {
28728 var intVal = toInt(value);
28729 maxlength = isNaN(intVal) ? -1 : intVal;
28730 ctrl.$validate();
28731 });
28732 ctrl.$validators.maxlength = function(modelValue, viewValue) {
28733 return (maxlength < 0) || ctrl.$isEmpty(viewValue) || (viewValue.length <= maxlength);
28734 };
28735 }
28736 };
28737};
28738
28739var minlengthDirective = function() {
28740 return {

Callers

nothing calls this directly

Calls 1

toIntFunction · 0.85

Tested by

no test coverage detected