Should you validate the output of DB query?

I know user input should always be validated before being stored in a DB, but what about query results? should they also be validated with zod or in a tRPC output function? interested to know if anyone has any thoughts on this.
Solution:
I personally wouldn't bother with it unless I'm transforming it further but if you want to do it you can either manually schema.parse in the body or rely on the .output property of the procedure to ensure its what you want
Jump to solution
2 Replies
Neto
Neto12mo ago
trpc allows you to validate the output
Solution
Keef
Keef12mo ago
I personally wouldn't bother with it unless I'm transforming it further but if you want to do it you can either manually schema.parse in the body or rely on the .output property of the procedure to ensure its what you want
Want results from more Discord servers?
Add your server
More Posts
Adding ISODate() for comparing dates in prisma with aggregateRaw on mongoDBHey guys hope you're doing all great!, I've been trying to compare dates using aggregations in mongoLambdas and Edge functions in same tRPC Project?How do you create a trpc app that uses both Lambdas and Edge functions (NextJS specifically)? Do youDeployed app not showing time in dateI`m using t3 stack with Supabase, on local machine I can query full date with time stamp without anyIntercepting Modal Cause Jump To Bottom Of PageLive: https://nextflix-blush.vercel.app/ Repo: https://github.com/Apestein/nextflix/tree/main/src/apt3 stack with a node/typescript/module example?Trying add a node service that is typed but when i import import { prisma } from "@acme/db"; say thI have been stuck on this Type error: Cannot find name 'TRPCError'. Did you mean 'RTCError'?https://i.imgur.com/19Sz2Ya.png https://i.imgur.com/fTNtGND.png I am following the 3 hour long chirpTRPC vanilla queries (T3 stack)Does anyone know how to access trpc vanilla queries (not hooks)? ```ts async function handler() { NextAuth errors.ts issueHas anyone else ran into this typescript issue with NextAuth's errors.ts file when running the buildSuggestions for a minimalist neovim settings?I am starting to use neovim and I would like some suggestions about the basic plugins and settings IHandling Long-Running Server Functions in Next.js: Seeking Alternatives to Vercel Time LimitsHey everyone! I'm working on a Next.js project where I need to sync and handle all new emails from a