T
tRPC

Is it possible to access context in input?

Is it possible to access context in input?

Ssafwan.rahman6/5/2023
Hi, I have a validator that requires to get context of prisma in the input, Is it possible to get the context in the input? There are some fields that are required for some users, I would like to handle this in validator level using zod.
Nnlucas6/5/2023
I believe when passing a function you can receive the context, but validators aren’t really intended to do that sort of work, just define the shape of the input, you could use a middleware or write these checks into the procedure

Looking for more? Join the community!

T
tRPC

Is it possible to access context in input?

Join Server