File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ Formsy.Form = React.createClass({
83
83
84
84
componentDidUpdate : function ( ) {
85
85
86
- if ( this . props . validationErrors ) {
86
+ if ( this . props . validationErrors && typeof this . props . validationErrors === 'object' && Object . keys ( this . props . validationErrors ) . length > 0 ) {
87
87
this . setInputValidationErrors ( this . props . validationErrors ) ;
88
88
}
89
89
Original file line number Diff line number Diff line change @@ -295,6 +295,29 @@ export default {
295
295
296
296
} ,
297
297
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
+
63D3
td>
316
+ test . done ( ) ;
317
+
318
+ } ,
319
+
320
+
298
321
'should override all error messages with error messages passed by form' : function ( test ) {
299
322
300
323
const TestForm = React . createClass ( {
You can’t perform that action at this time.
0 commit comments