You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using useForm in a react application, we have access to the function setError which has two overrides : one with a single error key and value, and another with an error object. The error object seems wrongly typed, because it assumes we always pass all key / value pair in the errors, which does not reflect the reality when used with validation libraries.
This is the current type 👇
errors: Record<keyofTForm,string>
It should probably be 👇
errors: Partial<Record<keyofTForm,string>>
In the same spirit, we currently create a lot of boilerplate code just to prevent sending the form when using validation librairies like zod/yup/joi etc. Would it be possible to consider accepting a resolver in the useForm hook configuration to prevent the sending of the form in case of validations error ? It would avoid unnecessary requests to the server and improve the DS similarly to what react-hook-form accepts.
Here is my current implementation with Yup as a reference 👇
Version:
@inertiajs/react
version: latestDescribe the problem:
When using
useForm
in a react application, we have access to the functionsetError
which has two overrides : one with a single error key and value, and another with an error object. The error object seems wrongly typed, because it assumes we always pass all key / value pair in the errors, which does not reflect the reality when used with validation libraries.This is the current type 👇
It should probably be 👇
In the same spirit, we currently create a lot of boilerplate code just to prevent sending the form when using validation librairies like zod/yup/joi etc. Would it be possible to consider accepting a resolver in the
useForm
hook configuration to prevent the sending of the form in case of validations error ? It would avoid unnecessary requests to the server and improve the DS similarly to whatreact-hook-form
accepts.Here is my current implementation with Yup as a reference 👇
Steps to reproduce:
setError
with an error object containing a single key/value pair -> TS errorsThe text was updated successfully, but these errors were encountered: