So I am adding validation to a form and I want to validate as much as possible on the frontend. Now I do believe some validation needs to be done by the backend, but I'll handle that after I've figured out what already has been validated by the frontend.
The things I want to validate are the following: - The user has selected/uploaded at least 3 files for the form - The files are of a accepted file type - The combined size of all files does not exceed a certain threshold
My initial thought was to just add the following to the form schema:
image: z.any().array().min(3, { message: "At least 3 files are required" }),
image: z.any().array().min(3, { message: "At least 3 files are required" }),
But the files are not in an array, they are instead bundled in an object like so:
"image": { "0": {}, "1": {}, "2": {} }
"image": { "0": {}, "1": {}, "2": {} }
So the first hurdle becomes how do I translate this into a Zod shape? This doesn't work