IdoPesok / zsa

https://zsa.vercel.app
MIT License
447 stars 13 forks source link

Support input formData entries with consistent field name #85

Closed GMkonan closed 1 month ago

GMkonan commented 1 month ago

Cases where a formData is passed with multiple entries with the same field name are not handled, so if we pass a formData to the server action that had several formData.append("name") on the client we will only get the last entry. Libs like zod-form-data handle this case automatically by turning the filed into an array.

I can provide more info if necessary, and If this is already possible, please correct me!

IdoPesok commented 1 month ago

Got it. I assume you are referring to repeatable. We do not have something built for this yet. I understand why this is important for zsa to handle.

If you can, can you provide an example on this issue of a server/client code pair for a simple form where this is breaking. We can then use this to test on our end (and add it to our tests)!

IdoPesok commented 1 month ago

Just merged a PR for this!

Please upgrade to zsa@0.3.1 and zsa-openapi@0.0.10

The TLDR is you want to use a z.array(z.string()). For a more comprehensive example, we posted a new section on our docs.

GMkonan commented 1 month ago

I was finishing a codesandbox to send as an example when I saw you already made a PR and merged. You are fast Sir! Tested and it seems to be working very well