Mismatch between Zod validators and transformed Date types #2122
alexanderhorner
started this conversation in
General
Replies: 1 comment 6 replies
-
Hey @alexanderhorner, yeah, this needs to be improved. Sorry for the trouble! |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context:
Using
@hey-api/openapi-ts
with@hey-api/transformers
turns allformat: date-time
fields intoDate
in the generated TypeScript interfaces. Meanwhile, adding the Zod plugin ('zod'
) produces Zod schemas that still validate those fields asstring
rather thanDate
.Problem:
"2025-06-04T12:00:00Z"
into aDate
.UserSchema.parse(userObj)
), it expectsuserObj.createdAt
to be astring
, not aDate
, causing a validation error.Request:
Is there an existing way (or plan) in
@hey-api/openapi-ts
to generate two Zod schemas per model:createdAt: string
) for validating before transformation, andcreatedAt: Date
) for validating after transformation?If no such feature exists, what’s the recommended approach to keep Zod validators in sync with transformed types without writing two separate schemas manually?
Beta Was this translation helpful? Give feedback.
All reactions