Skip to content

Commit

Permalink
handle nested array errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Mar 17, 2021
1 parent d646c2c commit 5a1a282
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/react/src/components/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ function parseApiError(error, values) {
key = '__other__';
}
if (Array.isArray(error)) {
// pass
if (typeof error[0] === 'object') {
errors[key] = error.map((err, i) =>
parseApiError(err, (values[key] || [])[i] || {})
);
return;
}
} else if (typeof error === 'object') {
errors[key] = parseApiError(error, values[key] || {});
return;
Expand Down

0 comments on commit 5a1a282

Please sign in to comment.