Skip to content

Commit

Permalink
Merge pull request #242 from easyrider/master
Browse files Browse the repository at this point in the history
Fix: Form.validationErrors disables input validation #239
  • Loading branch information
Semigradsky committed Nov 3, 2015
2 parents 300a53f + 8cf8409 commit cfebf17
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
23 changes: 23 additions & 0 deletions tests/Element-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Formsy.Form validationErrors={{}}>
<TestInput name="A" validations={{
isEmail: true
}} validationError="bar2" validationErrors={{isEmail: 'bar3'}} value="foo"/>
</Formsy.Form>
);
}
});
const form = TestUtils.renderIntoDocument(<TestForm/>);

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({
Expand Down

0 comments on commit cfebf17

Please sign in to comment.