Mikael LirbankM
Convex Community3y ago
17 replies
Mikael Lirbank

Input & Output Validators | tRPC

Are there any thoughts on adding output validators for functions to complement arg validators, similar to tRPC? https://trpc.io/docs/server/validators#output-validators

I love those coz

1) they make sure the return type is not changed when you change things in functions AND

2) since Zod "parse instead of validate", it prevents leaking data from the DB that you don't want to reach the client. Which is super super valuable.
tRPC procedures may define validation logic for their input and/or output, and validators are also used to infer the types of inputs and outputs. We have first class support for many popular validators, and you can integrate validators which we don't directly support.
Input & Output Validators | tRPC
Was this page helpful?