Enum<T extends Enum, Input = unknown>(Enum: T): Schema<T[keyof T], Input>
Enum: T
import * as x from 'unhoax'const Direction = { Left: 'LEFT', Right: 'RIGHT',} as const;enum Direction { Left = 'LEFT', Right = 'RIGHT',}enum Direction { Left, Right,}const schema = x.Enum(Direction)const result = schema.parse(Direction.Left)result // { success: true, value: Direction.Left }) Copy
import * as x from 'unhoax'const Direction = { Left: 'LEFT', Right: 'RIGHT',} as const;enum Direction { Left = 'LEFT', Right = 'RIGHT',}enum Direction { Left, Right,}const schema = x.Enum(Direction)const result = schema.parse(Direction.Left)result // { success: true, value: Direction.Left })
Example