Test if an unknown value is within a Typescript safe "union" values array
Value to test
"Union" values array
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)) { } Copy
const sheepNames = ['Capn Frisky', 'Mr. Snugs', 'Lambchop'] as const type SheepName = typeof sheepNames[number] if (isValidUnionValue(JSON.parse('"Capn Frisky"'), sheepNames)) { }
Test if an unknown value is within a Typescript safe "union" values array