Replies: 2 comments 2 replies
-
After continuing to read and look into this a bit more, I'm thinking this idea might be a misunderstanding of purely "typing" (Prisma) and "validation" (Zod). I recognize that Zod can handle typing as well, but maybe that's part of the reason these are separate? I'd greatly appreciate if anyone could elaborate here, if I'm thinking about this correctly or if I'm way off base. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello all. Jsyk, I'm fairly new to typescript (tRPC got me to start learning!) so I apologize if this is a silly question.
Anyway, I've been playing with tRPC, zod, and Prisma types and that made me wonder if there is a way to use the types generated by prisma to validate inputs.
For example, here is a setup with zod, but I've noticed things like find, create, update can get pretty complex (like if I want to be able to reuse my block schema within those actions. In this case I might need to set some or all of my parameter as optional (or use
pick
oromit
... etc)).But if you're using Prisma, those different types are generated for you. And since the types are generated from your DB schema it might be nice to leverage those types without having to manage your zod types as well. So it'd be nice to be able to do something like this:
Beta Was this translation helpful? Give feedback.
All reactions