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

Function optionalString

projects/runtime-protocol/src/protocol.ts:416–421  ·  view source on GitHub ↗
(record: Record<string, unknown>, key: string)

Source from the content-addressed store, hash-verified

414}
415
416function optionalString(record: Record<string, unknown>, key: string): RuntimeValidationResult<string | undefined> {
417 const value = record[key]
418 if (value === undefined) return { ok: true, value: undefined }
419 if (typeof value !== "string") return paramsError(`$.${key}`, `${key} must be a string`)
420 return { ok: true, value }
421}
422
423function requiredString(record: Record<string, unknown>, key: string): RuntimeValidationResult<string> {
424 const value = record[key]

Callers 3

Calls 1

paramsErrorFunction · 0.70

Tested by

no test coverage detected