Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(input): make maxlength and minlength work with non-string values #8205

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/ng/directive/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2318,7 +2318,10 @@ var maxlengthDirective = function() {
maxlength = int(value) || 0;
ctrl.$validate();
});
ctrl.$validators.maxlength = function(value) {
ctrl.$validators.maxlength = function(value, viewValue) {
if (!isString(value)) {
value = viewValue;
}
return ctrl.$isEmpty(value) || value.length <= maxlength;
};
}
Expand All @@ -2336,7 +2339,10 @@ var minlengthDirective = function() {
minlength = int(value) || 0;
ctrl.$validate();
});
ctrl.$validators.minlength = function(value) {
ctrl.$validators.minlength = function(value, viewValue) {
if (!isString(value)) {
value = viewValue;
}
return ctrl.$isEmpty(value) || value.length >= minlength;
};
}
Expand Down