Skip to content
masterclass Buddy

Zod · Function

z.union

z.union() validates input against several schemas. It succeeds when one option matches and returns the first successful result.

Last updated

Syntax

z.union([schemaA, schemaB, ...])

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • z.xor()
  • z.discriminatedUnion()
  • z.intersection()
  • options

Source: Defining schemas | Zod. Checked 2026-11-03.