react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

Add server side validation support

Open djhi opened this issue 3 years ago • 0 comments

Problem

  • Server side validation is cumbersome to set up
  • When using middlewares and as the SaveButton relied on the SaveContext.saving prop, the SaveButton was only disabled for while the main mutation was loading. However, additional work may still be running.

Solution

For pessismistic mode only, we now transparently support server side validation. When a server validation occurs, the DataProvider should throw an error that contains an errors object matching the form shape.

Besides, we now await the mutation in useCreateController and useEditController. In pessimistic mode, that means the SaveButton will stay disabled until the mutation is resolved including its middlewares if any.

That does not change anything for the other mutation modes.

djhi avatar Jul 07 '22 08:07 djhi