From 2a384f40a6754133627ac27cf9f9a5a3983f87fa Mon Sep 17 00:00:00 2001 From: "adam.dymowski" Date: Mon, 19 Oct 2015 16:19:03 +0200 Subject: [PATCH 1/2] Fix: Form.validationErrors disables input validation #239 --- src/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index bf4a3ee..cec25a1 100644 --- a/src/main.js +++ b/src/main.js @@ -83,7 +83,7 @@ Formsy.Form = React.createClass({ componentDidUpdate: function () { - if (this.props.validationErrors) { + if (this.props.validationErrors && typeof this.props.validationErrors === 'object' && Object.keys(this.props.validationErrors).length > 0) { this.setInputValidationErrors(this.props.validationErrors); } From 8cf8409e3a42b1d57d6849df2a8e09495ebd4ccb Mon Sep 17 00:00:00 2001 From: "adam.dymowski" Date: Tue, 20 Oct 2015 09:19:24 +0200 Subject: [PATCH 2/2] Fix: Form.validationErrors disables input validation #239 --- tests/Element-spec.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/Element-spec.js b/tests/Element-spec.js index 90be589..83acf34 100644 --- a/tests/Element-spec.js +++ b/tests/Element-spec.js @@ -295,6 +295,29 @@ export default { }, + 'should not override error messages with error messages passed by form if passed eror messages is an empty object': function (test) { + + const TestForm = React.createClass({ + render() { + return ( + + + + ); + } + }); + const form = TestUtils.renderIntoDocument(); + + const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput); + test.equal(inputComponent.getErrorMessage(), 'bar3'); + + test.done(); + + }, + + 'should override all error messages with error messages passed by form': function (test) { const TestForm = React.createClass({