final-form / final-form/react-final-form-arrays

Validate errors on field arrays

Open
#11 12 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
210
Forks
69
PR merge metrics
No merged PRs in 30d

Description

Follow discussion here: https://github.com/final-form/react-final-form-arrays/issues/3#issuecomment-351748774

[![Edit RFF Field Array Problem](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/xvrv30p95q)

When mixed field with field arrays, the form cannot submit due to `errors` object can never be empty ie.

```json
Form errors:
{
"customers": [
{}
]
}
```

I understand the reason for field arrays keys here, but I have to write workarounds such as:

```js
onSubmit = () => {
this.formEl.dispatchEvent(new Event('submit')); // trigger final-form submit
this.submit(); // check if "errors.customers" array is full of empty object and submit
}
```

Just an idea - could we expose validation function (the function which checks for form errors then execute `props.onSubmit()`) to make it more flexible for this usecase?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.