8000 Merge pull request #242 from easyrider/master · coderabsolute/formsy-react@cfebf17 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit cfebf17

Browse files
committed
Merge pull request christianalfoni#242 from easyrider/master
Fix: Form.validationErrors disables input validation christianalfoni#239
2 parents 300a53f + 8cf8409 commit cfebf17

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Formsy.Form = React.createClass({
8383

8484
componentDidUpdate: function () {
8585

86-
if (this.props.validationErrors) {
86+
if (this.props.validationErrors && typeof this.props.validationErrors === 'object' && Object.keys(this.props.validationErrors).length > 0) {
8787
this.setInputValidationErrors(this.props.validationErrors);
8888
}
8989

tests/Element-spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,29 @@ export default {
295295

296296
},
297297

298+
'should not override error messages with error messages passed by form if passed eror messages is an empty object': function (test) {
299+
300+
const TestForm = React.createClass({
301+
render() {
302+
return (
303+
<Formsy.Form validationErrors={{}}>
304+
<TestInput name="A" validations={{
305+
isEmail: true
306+
}} validationError="bar2" validationErrors={{isEmail: 'bar3'}} value="foo"/>
307+
</Formsy.Form>
308+
);
309+
}
310+
});
311+
const form = TestUtils.renderIntoDocument(<TestForm/>);
312+
313+
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
314+
test.equal(inputComponent.getErrorMessage(), 'bar3');
315+
316+
test.done();
317+
318+
},
319+
320+
298321
'should override all error messages with error messages passed by form': function (test) {
299322

300323
const TestForm = React.createClass({

0 commit comments

Comments
 (0)
0