Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Go to Latest
method zod.z.ZodDiscriminatedUnion.create
import { zod } from "https://deno.land/x/cav@0.2.0-alpha.7/test/deps.ts";
const { ZodDiscriminatedUnion } = zod.z;

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.

Parameters

discriminator: Discriminator

the name of the discriminator property

types: Types

an array of object schemas

optional
params: RawCreateParams