Skip to content
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
@jackwlee01

Description

@jackwlee01

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions