MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / optionalStringDef

Function optionalStringDef

src/lib/item-input/misc.ts:46–59  ·  view source on GitHub ↗
(name: string, options?: StringDefOptions)

Source from the content-addressed store, hash-verified

44 validate?: InputDefinitionValidateFunction<string>
45}
46export const optionalStringDef = (name: string, options?: StringDefOptions): InputDefinition<string | undefined> => {
47 const buildFromUserInput = async (context?: unknown[]): Promise<string | undefined> =>
48 optionalStringInput(`${name} (optional)`, {
49 ...options,
50 default: defaultWithContextFn(options?.default, context),
51 validate: validateWithContextFn(options?.validate, context),
52 })
53 const summarizeForEdit = (value: string): string => value
54 const updateFromUserInput = (original: string, context?: unknown[]): Promise<string | undefined> =>
55 optionalStringInput(`${name} (optional)`,
56 { ...options, default: original, validate: validateWithContextFn(options?.validate, context) })
57
58 return { name, buildFromUserInput, summarizeForEdit, updateFromUserInput }
59}
60
61export const stringDef = (name: string, options?: StringDefOptions): InputDefinition<string> => {
62 const buildFromUserInput = async (context?: unknown[]): Promise<string> =>

Callers 6

getInputFromUserFunction · 0.85
buildInputDefinitionFunction · 0.85
arnDefFunction · 0.85
misc.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected