Search


Search something to see results

union

If you want to use a discriminated union, checkout variant

Type Parameters

Parameters

  • schemas: T

Returns UnionSchema<TypeOf<T[number]>, InputOf<T[number]>>

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' }