union<T extends [Schema<any, any>, ...Schema<any, any>[]]>( ...schemas: T,): UnionSchema<TypeOf<T[number]>, InputOf<T[number]>>
If you want to use a discriminated union, checkout variant
…schemas: T
import * as x from 'unhoax'const schema = x.union(x.string, x.number) // Schema<string | number>const result = schema.parse('a')result // { success: true, value: 'a' } Copy
import * as x from 'unhoax'const schema = x.union(x.string, x.number) // Schema<string | number>const result = schema.parse('a')result // { success: true, value: 'a' }
If you want to use a discriminated union, checkout variant