diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js
index 53a8ddd4d70a..748e71d6e619 100644
--- a/src/ng/directive/input.js
+++ b/src/ng/directive/input.js
@@ -518,7 +518,8 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
if (attr.ngMinlength) {
var minlength = int(attr.ngMinlength);
var minLengthValidator = function(value) {
- return validate(ctrl, 'minlength', ctrl.$isEmpty(value) || value.length >= minlength, value);
+ return validate(ctrl, 'minlength', ctrl.$isEmpty(value) ||
+ (isDefined(value.length) ? value.length : Infinity) >= minlength, value);
};
ctrl.$parsers.push(minLengthValidator);
@@ -529,7 +530,8 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
if (attr.ngMaxlength) {
var maxlength = int(attr.ngMaxlength);
var maxLengthValidator = function(value) {
- return validate(ctrl, 'maxlength', ctrl.$isEmpty(value) || value.length <= maxlength, value);
+ return validate(ctrl, 'maxlength', ctrl.$isEmpty(value) ||
+ (isDefined(value.length) ? value.length : -Infinity) <= maxlength, value);
};
ctrl.$parsers.push(maxLengthValidator);
diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js
index 668fa0b54a1e..79a6a041176b 100644
--- a/test/ng/directive/inputSpec.js
+++ b/test/ng/directive/inputSpec.js
@@ -733,6 +733,16 @@ describe('input', function() {
changeInputValueTo('aaa');
expect(scope.value).toBe('aaa');
});
+
+ it('should not invalidate model-values which are not string-like or array-like', function() {
+ compileInput('');
+
+ scope.$apply(function() {
+ scope.value = 10;
+ });
+
+ expect(inputElm).toBeValid();
+ });
});
@@ -747,6 +757,16 @@ describe('input', function() {
changeInputValueTo('aaa');
expect(scope.value).toBe('aaa');
});
+
+ it('should not invalidate model-values which are not string-like or array-like', function() {
+ compileInput('');
+
+ scope.$apply(function() {
+ scope.value = 1000;
+ });
+
+ expect(inputElm).toBeValid();
+ });
});