Skip to content

Commit

Permalink
Merge pull request #18 from mprzodala/fixObjectFieldValidation
Browse files Browse the repository at this point in the history
Fix object field validation
  • Loading branch information
mprzodala authored May 16, 2017
2 parents fcb753f + f98b004 commit 0aa0d17
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Bootstrap.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-components-form",
"version": "2.0.0",
"version": "2.1.1",
"description": "React form components",
"main": "main.js",
"jsnext:main": "src/index.js",
Expand Down
8 changes: 2 additions & 6 deletions src/components/ObjectField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,8 @@ export class ObjectField extends React.Component {
getErrors(name) {
const { getErrors } = this.context;
const errors = getErrors(this.props.name);
if(Array.isArray(errors)){
const returnedErrors = [];
errors.forEach(error => {
if (error[name]) returnedErrors.push(error[name]);
});
return returnedErrors;
if(Array.isArray(errors) && errors.length === 1){
return errors[0][name] || [];
}
return errors[name] || [];
}
Expand Down

0 comments on commit 0aa0d17

Please sign in to comment.