Create built-in support for formData #1860
Replies: 2 comments 8 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.
-
This has been discussed (though that's marked as answered). Here's my own implementation of a utility that pre-processes a
FormData
object 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