MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / optionalStringEnum

Function optionalStringEnum

projects/runtime-node/src/validation.ts:45–52  ·  view source on GitHub ↗
(key: string, values: readonly string[])

Source from the content-addressed store, hash-verified

43}
44
45export function optionalStringEnum(key: string, values: readonly string[]): ParamCheck {
46 return (record) => {
47 const value = record[key]
48 if (value === undefined) return null
49 if (typeof value !== "string" || !values.includes(value)) return paramsError(`$.${key}`, `${key} must be one of: ${values.join(", ")}`)
50 return null
51 }
52}
53
54export function optionalBoolean(key: string): ParamCheck {
55 return (record) => {

Callers 1

files.tsFile · 0.90

Calls 1

paramsErrorFunction · 0.70

Tested by

no test coverage detected