This repository was archived by the owner on Nov 19, 2024. It is now read-only.
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
Support for union or discriminatedUnion? #255
Open
Description
The following code produces a runtime error:
thing: publicProcedure
.meta({ openapi: { method: 'GET', path: '/api/thing' }})
.input( z.union([
z.object({ type: z.literal('first'), myVar: z.string() }),
z.object({ type: z.literal('another'), anotherVar: z.number() }),
z.object({ type: z.literal('third') }),
]))
.output( z.string() )
.query(({ ctx }) => "thing" ),
TRPCError: [query.thing] - Input parser must be a ZodObject
Is there any planned support for union or discriminatedUnion?