Function isOneOf

  • Asserts that a value is one of the provided values.

    Type Parameters

    • T = unknown

    Parameters

    • val: T

      Value to check

    • values: T[]

      Array of allowed values

    • OptionalerrorOrMessage: string | Error

      Error object or message to throw if the value is not one of the allowed values

    Returns asserts val is T