Skip to main content

$enum

Callable

  • $enum<Values>(values: Values, options?: SchemaOptions<object, Values[number]>): EnumType<Values>
  • $enum<Values>(values: Values, options?: SchemaOptions<object, Values[keyof Values]>): NativeEnumType<Values>

  • Declares an EnumType. This is either a list of values, or a dictionary where the key is the name of value.

    Example

    $enum([1, 3])

    $enum(["foobar"])

    Type parameters

    • Values: string[]

    Parameters

    • values: Values

      The values that are allowed on this property.

    • optionaloptions: SchemaOptions<object, Values[number]>

      Additional options to pass to the enum.

    Returns EnumType<Values>