found value if found
const sheepNames = ['Capn Frisky', 'Mr. Snugs', 'Lambchop'] as const
type SheepName = typeof sheepNames[number]
try {
const validValue: SheepName = findValidUnionValue(JSON.parse('"Capn Frisky"'), sheepNames)
} catch (e) {
if (e instanceof InvalidUnionValueException) {
console.error(e.message)
return
}
throw e
}
Find if an unknown value is within a Typescript safe "union" values array