Create built-in support for formData #1860
Replies: 3 comments 9 replies
-
|
Gonna leave Kent hanging on this one? smh The zod-form-data lib works but native integration would be great |
Beta Was this translation helpful? Give feedback.
-
|
For now a workaround without using a third-party-library is to objectify the form data. validator.parse(Object.fromEntries(formData.entries()));
EDIT: The one time I post something... Well there is a downside. Additionally there isn't really a great way to automatically deal with arrays. While you certainly can just do I still believe this can be a good approach. |
Beta Was this translation helpful? Give feedback.
-
|
I was using https://github.com/airjp73/rvf/tree/main/packages/zod-form-data for this, but I don't think it supports Zod 4 unfortunately. Does anyone know of any similar tools with Zod 4 support? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This has been discussed (though that's marked as answered). Here's my own implementation of a utility that pre-processes a
FormDataobject based on a given schema so it can be converted into a regular object via.parse:Here's how I'm using that in a Remix action:
This works well for me, but I feel like it would be better to be built-in and would like to discuss doing something like that.
We talked about this a bit on twitter as well: https://twitter.com/colinhacks/status/1611474885188161536
Beta Was this translation helpful? Give feedback.
All reactions