class z.ZodDiscriminatedUnion
extends ZodType<output<Options[number]>, ZodDiscriminatedUnionDef<Discriminator, Options>, input<Options[number]>>
import { z } from "https://deno.land/x/pup@1.0.0-beta.34/deps.ts";
const { ZodDiscriminatedUnion } = z;
Type Parameters
Options extends ZodDiscriminatedUnionOption<Discriminator>[]
Methods
_parse(input: ParseInput): ParseReturnType<this["_output"]>
Static Methods
create<Discriminator extends string, Types extends [ZodDiscriminatedUnionOption<Discriminator>, ...ZodDiscriminatedUnionOption<Discriminator>[]]>(): ZodDiscriminatedUnion<Discriminator, Types>
The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. However, it only allows a union of objects, all of which need to share a discriminator property. This property must have a different value for each object in the union.