Skip to content

Commit 9f964df

Browse files
committed
Verify value is defined before trying to run a min/max length value.
this will help avoid a TypeError.
1 parent 531cb12 commit 9f964df

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

dist/angular-validation-rule.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
email: /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/,
1111
number: /^\d+$/,
1212
minlength: function(value, scope, element, attrs, param) {
13-
return value.length >= param;
13+
return value && value.length >= param;
1414
},
1515
maxlength: function(value, scope, element, attrs, param) {
16-
return value.length <= param;
16+
return !value || value.length <= param;
1717
}
1818
};
1919

dist/angular-validation-rule.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rule.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
email: /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/,
1111
number: /^\d+$/,
1212
minlength: function(value, scope, element, attrs, param) {
13-
return value.length >= param;
13+
return value && value.length >= param;
1414
},
1515
maxlength: function(value, scope, element, attrs, param) {
16-
return value.length <= param;
16+
return !value || value.length <= param;
1717
}
1818
};
1919

0 commit comments

Comments
 (0)