How to Convert Complex TypeScript Interfaces to Zod Schema? #3885
Unanswered
alan890104
asked this question in
Q&A
Replies: 1 comment
-
Haven't tried it, but the ts-to-zod seems to fit your needs. I'm sure you're aware, going "types first" means opting out of advanced Zod features, as described in the docs:
To support these use cases, you would have to implement additional logic. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone,
I'm working on a TypeScript project and need to convert a set of complex interfaces into a Zod schema for runtime validation. Here's a simplified example of the interfaces I'm working with:
My goal is to create Zod schemas for these types, especially for
WithdrawParams
, which involves unions and nested objects. I'm unsure how to handle the more complex parts, like:SingleWithdrawParams
andBalancedWithdrawParams
)withdrawAsset
andnextWithdraw
)NextWithdraw
)The rules:
Could anyone provide guidance or examples of how to translate these interfaces into Zod schemas? Any advice or resources would be greatly appreciated!
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions