chrishoermann / zod-prisma-types

Generator creates zod types for your prisma models with advanced validation
Other
654 stars 49 forks source link

Omit Fields In Where Schemas #97

Open OsamaAburabie opened 1 year ago

OsamaAburabie commented 1 year ago

Is there a way to omit fields by the generator on "where" schemas for now it only does in on the "input" schemas.

chrishoermann commented 1 year ago

@OsamaAburabie no the omit fields are not propagated to where schemas. Would this be really necessary for you since the fields in where inputs should be optional by default anyway?

OsamaAburabie commented 1 year ago

@chrishoermann I'm playing with trpc and had an idea to expose the "where" block to the client so they can query whatever they like but using this technique I might need to omit some sensitive fields from the where block😅 what do you think?

chrishoermann commented 1 year ago

@OsamaAburabie I'think it is definitly possible but it would require some work to implement it in a way that only the where block is affected by the field omission. We'd need some rich-comment annotation like .omit([where]) that works on every validator type (like the array() validator) but is only added on where inputs. I'll keep it on my radar but I can not guarantee that I can implement it anytime soon. 😐