Skip to content

Commit

Permalink
fix: empty object in errors when field has array type
Browse files Browse the repository at this point in the history
  • Loading branch information
ZirionNeft committed Aug 2, 2021
1 parent 65fb681 commit f5d44ca
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ function getErrorsFromSchema(initialValues, schema, errors = {}) {
case schema[key].type === 'array': {
const values =
initialValues && initialValues[key] ? initialValues[key] : [];
errors[key] = values.map((value) =>
getErrorsFromSchema(

errors[key] = values.map((value) => {
const innerError = getErrorsFromSchema(
value,
schema[key].innerType.fields,
Object.assign({}, errors[key]),
),
);
);
return Object.keys(innerError).length > 0 ? innerError : '';
});
break;
}

Expand Down

0 comments on commit f5d44ca

Please sign in to comment.