The union conditional type
Array of conditional branches to evaluate
Wrap a schema inside a conditional branch. The condition is evaluated at runtime, and if it returns a truthy value, the associated schema is used for validation.
The schema type to apply when condition matches
Function that evaluates whether this branch should be used
The schema to apply if the condition is true
Wrap a schema inside an else (default) conditional. This branch always matches and should be placed last in the union conditionals array.
The schema type to apply as default
The schema to apply when no other conditions match
Create a new union schema type. A union is a collection of conditionals and schema associated with it.
Unions evaluate conditionals in order and apply the first matching schema. Use
union.if()to define conditional branches andunion.else()for the default fallback.