semajy - Hello! I'm sort of new to typescript a...
Hello! I'm sort of new to typescript and Zod and I'm at the point where I have types that were generated based on my mysql schema (using kysely-codegen). Of course I also want to validate types at runtime made from server requests. Is it really the best way that I manually create Zod schemas based on these types?
Solution:Jump to solution
In actuality I only need Zod primarily for input validation from sources I don't have control over, which also means primarily validating a version of an entity or "type" that is either for updating or selecting
4 Replies
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
I don't quite get what you're saying
That being said, I've since realized my mental model of this is faulty and I was originally thinking that I would need a 1:1 mapping of types to Zod schemas
Solution
In actuality I only need Zod primarily for input validation from sources I don't have control over, which also means primarily validating a version of an entity or "type" that is either for updating or selecting
So if I have a user that has 5 fields, and I want to update that user, I may only really need to validate 3 of those fields
or whatever fields are exposed to user input
Thanks for the help anyways!