final-form / final-form/react-final-form-arrays
Validate errors on field arrays
- 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
[](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
Assessment
This issue has not been assessed yet.