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

Function optionalIntegerDef

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

Source from the content-addressed store, hash-verified

78 default?: InputDefinitionDefaultValueOrFn<number>
79}
80export const optionalIntegerDef = (name: string, options?: NumberDefOptions): InputDefinition<number | undefined> => {
81 const buildFromUserInput = async (context?: unknown[]): Promise<number | undefined> =>
82 optionalIntegerInput(`${name} (optional)`, {
83 ...options,
84 default: defaultWithContextFn(options?.default, context),
85 validate: validateWithContextFn<number | undefined>(options?.validate, context),
86 })
87 const summarizeForEdit = (value: number | undefined): string => String(value)
88 const updateFromUserInput = (original: number | undefined, context?: unknown[]): Promise<number | undefined> =>
89 optionalIntegerInput(`${name} (optional)`,
90 { ...options, default: original, validate: validateWithContextFn<number | undefined>(options?.validate, context) })
91
92 return { name, buildFromUserInput, summarizeForEdit, updateFromUserInput }
93}
94export const integerDef = (name: string, options?: NumberDefOptions): InputDefinition<number> => {
95 const buildFromUserInput = async (context?: unknown[]): Promise<number> =>
96 integerInput(name, {

Callers 2

getInputFromUserFunction · 0.85
misc.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected