tRPCttRPC
Powered by
BarakondaB
tRPC•3y ago•
11 replies
Barakonda

input using z.or not working properly

i have an input like this
let input = z.object({
name: z.string().optional()
}).or(z.object({
id: z.number().optional()
}));
when I call the route with { name: "123" } I get in the input { name: "123" } properly like I should,
but when I call the same route with { id: 2 } then I get in the input {} - the rawInput is correctly { id: 2 } but
the data is not transferred to input, when I switch the order of the input like this
let input = z.object({
id: z.number().optional()
}).or(z.object({
name: z.string().optional()
}));
then now, id is the one that works and name gives {}
this is probably a bug, should I post this in the git or maybe it wasn't supposed to work at all?
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

z.map() as an input
VengeanceVVengeance / ❓-help
4y ago
types not working if input provided
fynnFfynn / ❓-help
7mo ago
empty `input` object when using mutation
KrishnaKKrishna / ❓-help
3y ago
Bug: Setting up cookies not woring when using .input in nextjs
Answer OverflowAAnswer Overflow / ❓-help
2y ago