Function enum

  • Creates the shape that constrains input with the array of values.

    Type Parameters

    • Value extends Any

      The union of allowed enum values.

    • ValuesArray extends readonly [Value, Value]

      The array of allowed values.

    Parameters

    • values: ValuesArray

      The array of values allowed for the input.

    • Optional options: IssueOptions | Message

      The issue options or the issue message.

    Returns EnumShape<ValuesArray[number]>

  • Creates the shape that constrains input with values of the enum-like object.

    Type Parameters

    • Value extends Any

      The union of allowed enum values.

    • ValuesDict extends ReadonlyDict<Value>

      The object that maps from the key to an enum value.

    Parameters

    • values: ValuesDict

      The native enum or a mapping object.

    • Optional options: IssueOptions | Message

      The issue options or the issue message.

    Returns EnumShape<ValuesDict[keyof ValuesDict]>