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
It would be great if the inputValidator checks if the data is an instanceof FormData and then it validates the FormData with zod as is done in zod-form-data
Then, we would be able to just have this also with the body as FormData and get a type safe result without extra wrapers:
// Body is FormDataexportconstcreateUser=createServerFn({method: 'POST'}).inputValidator(UserSchema).handler(async({ data })=>{// data is fully typed and validatedreturn`Created user: ${data.name}, age ${data.age}`})
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Right now, the documentation suggests validating the formData by checking for an instance of it.
That requires extra logic to be built on every
inputValidatorand is not a great DX.It would be great if the
inputValidatorchecks if the data is aninstanceof FormDataand then it validates theFormDatawith zod as is done in zod-form-dataThen, we would be able to just have this also with the body as
FormDataand get a type safe result without extra wrapers:Beta Was this translation helpful? Give feedback.
All reactions