Zod File Upload validation

I'm currently making a file upload form
is there any way to validate a file in zod?
I tried this https://github.com/colinhacks/zod/issues/387#issuecomment-1191390673
but it didn't seem to work
No matter what file i upload it just says image is required
https://rentry.co/ndimv
A gist of my code
const MAX_FILE_SIZE = 500000
const ACCEPTED_IMAGE_TYPES = [
"image/jpeg",
"image/jpg",
"image/png",
"image/webp",
]
const formSchema = z.object({
course_id: z.string().min(1, { message: "Course name is required" }),
year: z.string().m...
GitHub
Coming from Yup. I'm trying to validate a required file input with no success: file: z.any().refine(val => val.length > 0, "File is required") Any tips?
Was this page helpful?