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

Function requiredString

projects/runtime-node/src/validation.ts:27–35  ·  view source on GitHub ↗
(key: string, options: { allowEmpty?: boolean } = {})

Source from the content-addressed store, hash-verified

25}
26
27export function requiredString(key: string, options: { allowEmpty?: boolean } = {}): ParamCheck {
28 return (record) => {
29 const value = record[key]
30 if (typeof value !== "string" || (!options.allowEmpty && value.length < 1)) {
31 return paramsError(`$.${key}`, `${key} must be ${options.allowEmpty ? "a string" : "a non-empty string"}`)
32 }
33 return null
34 }
35}
36
37export function optionalString(key: string): ParamCheck {
38 return (record) => {

Callers 8

commandParamsFunction · 0.90
scriptParamsFunction · 0.90
ptySpawnParamsFunction · 0.90

Calls 1

paramsErrorFunction · 0.70

Tested by

no test coverage detected