diff --git a/modules/validate/test/validateSpec.js b/modules/validate/test/validateSpec.js
index 35275a22..411877e2 100644
--- a/modules/validate/test/validateSpec.js
+++ b/modules/validate/test/validateSpec.js
@@ -47,6 +47,17 @@ describe('uiValidate', function () {
expect(scope.form.input.$valid).toBeFalsy();
expect(scope.form.input.$error).toEqual({ validator: true });
}));
+
+ it('should keep the invalid value in model if it is marked as invalid', inject(function () {
+
+ var testValue = 'test123';
+ scope.value = testValue;
+ scope.validate = falseValidator;
+ var inputElm = compileAndDigest('', scope);
+ expect(scope.form.input.$valid).toBeFalsy();
+ expect(scope.value).toEqual(testValue);
+ expect(inputElm.val()).toEqual(testValue);
+ }));
});
describe('validation on model change', function () {
@@ -96,6 +107,19 @@ describe('uiValidate', function () {
expect(scope.form.input.$error.key1).toBeFalsy();
expect(scope.form.input.$error.key2).toBeTruthy();
});
+
+ it('should show subsequent validation errors as false if the first of multiple validators fails, but the other validations do not fail', function () {
+
+ scope.validate1 = falseValidator;
+ scope.validate2 = trueValidator;
+ scope.validate3 = trueValidator;
+
+ compileAndDigest('', scope);
+ expect(scope.form.input.$valid).toBeFalsy();
+ expect(scope.form.input.$error.key1).toBeTruthy();
+ expect(scope.form.input.$error.key2).toBeFalsy();
+ expect(scope.form.input.$error.key3).toBeFalsy();
+ });
});
describe('uiValidateWatch', function(){
diff --git a/modules/validate/validate.js b/modules/validate/validate.js
index fb315351..c794b45e 100644
--- a/modules/validate/validate.js
+++ b/modules/validate/validate.js
@@ -49,7 +49,7 @@ angular.module('ui.validate',[]).directive('uiValidate', function () {
} else {
// expression is false
ctrl.$setValidity(key, false);
- return undefined;
+ return valueToValidate;
}
};
validators[key] = validateFn;