Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zodix modifying FormData objects #31

Open
elico5 opened this issue Jan 19, 2023 · 0 comments
Open

Zodix modifying FormData objects #31

elico5 opened this issue Jan 19, 2023 · 0 comments

Comments

@elico5
Copy link

elico5 commented Jan 19, 2023

Thanks for the library! Is there a reason Zodix modifies incoming FormData objects (https://github.com/rileytomasek/zodix/blob/master/src/parsers.ts#L189)? We just found a regression in our app related to this behavior as it pertains to FormData with file uploads.

We have a Remix action function that handles incoming FormData differently depending on the FormData's subaction, and one of these handlers expects a File to be present in FormData. We initially use Zodix to parse the subaction via a call to parseFormSafe. Once we know the subaction we pass the FormData towards further Zod validation (variable schema depending on the subaction). Before parsing through Zodix formData.get('file') yields a File object (expected by our downstream validation schema), and then after it yields a string (ex. '{"_name":"file.json","_lastModified":1674149960469}') which causes the downstream schema to fail.

We're giving Zodix a request clone as a workaround, but wanted to toss this behavior on the radar as we would like to unwind it eventually if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant