Should you share zod schema from server side to client side?

I have a zod schema which is used to validate trpc router procedure on server, and I need same schema to validate input on client side form, so, is there any security threat, if I import that server schema on client component?
7 Replies
nimeshvaghasiya
nimeshvaghasiyaOP3y ago
@stoyko
Neto
Neto3y ago
as long you dont export from the same folder of the router, is fine you can make a shared folder that holds code for both sides
barry
barry3y ago
Also don’t just tag people randomly
stoyko
stoyko3y ago
I was so confused for a moment, because I’m just doing something for work with zod and graphql….
BarisP
BarisP3y ago
You can infer the types from procedures' input or output src/utils/trpc.ts / * Inference helpers * @example type HelloOutput = RouterTypes['example']['hello']['output'] / export type RouterTypes = GetInferenceHelpers<AppRouter>;
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
nimeshvaghasiya
nimeshvaghasiyaOP3y ago
I have search 'zod schema' and got stoyko's comment here https://discord.com/channels/966627436387266600/966627439390380064/1050343129766703104, so I thought, better to mention stoyko. my bad that I have only mentioned him without comment.
Discord
Discord - A New Way to Chat with Friends & Communities
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
Want results from more Discord servers?
Add your server