Next.js Discord

Discord Forum

How to validate appended files array in Zod in server action

Unanswered
Waldo posted this in #help-forum
Open in Discord
If I append a bunch of Files (images, photos) using FormData to the same key as you see in my code. Is it possible to validate that with Zod? I can't figure it out. If I use z.array(z.instanceOf(File)) it's not an array. Suppose I use z.any().transform(file => ...) it will only see the last File appended, but NOT the whole array of Files. So how do I validate something like that with Zod?

1 Reply

Is it possible to validate that with Zod?
My want to get zod-formdata

or if you fancy, just get react-hook-form since it works well with zod