Merge pull request #242 from easyrider/master

Fix: Form.validationErrors disables input validation #239
This commit is contained in:
Dmitry Semigradsky 2015-11-03 14:34:45 +03:00
commit cfebf17aea
2 changed files with 24 additions and 1 deletions

View File

@ -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);
}

View File

@ -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({