Search


Search something to see results

Enum

Type Parameters

  • T extends Enum
  • Input = unknown

Parameters

  • Enum: T

Returns Schema<T[keyof T], Input>

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