Use server-side validation response in react-admin

2020-06-16 05:27发布

问题:

In my app using react-admin I have a few forms where the validation must be performed on the server side. My API (implemented with api-platform) returns a 400 response with a key in its body that contains an array of the constraint violations, keyed to the field names, so the information is there to provide field-by-field error messages.

This issue is the same explored in this old question. However, since react-admin moved from redux-form to react-final-form, solutions based on an error saga do not work anymore.

The example given in the official react-final-form docs is not easy to apply because react-admin manages the onSubmit property by itself.