@adorkable/eunomia-typescript
    Preparing search index...

    Function isValidUnionValue

    • Test if an unknown value is within a Typescript safe "union" values array

      Type Parameters

      • T
      • V

      Parameters

      • value: V

        Value to test

      • values: readonly T[]

        "Union" values array

      Returns boolean

      true if value is valid, otherwise false

      unexpected Errors

      const sheepNames = ['Capn Frisky', 'Mr. Snugs', 'Lambchop'] as const
      type SheepName = typeof sheepNames[number]
      if (isValidUnionValue(JSON.parse('"Capn Frisky"'), sheepNames)) {
      }