Search
Star
Feedback
Setup for Free
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
Zod File Upload validation - Theo's Typesafe Cult
TTC
Theo's Typesafe Cult
•
3y ago
•
96 replies
fosslover
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
// Imports go here
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
Validating file input · Issue #387 · colinhacks/zod
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
?
Theo's Typesafe Cult
Join
26,131
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Similar Threads
Was this page helpful?
Yes
No
Similar Threads
Zod File Upload Validation with Open-Api Support?
TTC
Theo's Typesafe Cult / questions
3y ago
Zod File Upload Validation with Open-Api Support?
TTC
Theo's Typesafe Cult / questions
3y ago
Prisma zod enum validation
TTC
Theo's Typesafe Cult / questions
3y ago
Next page