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

Function numberValidateFn

src/lib/validate-util.ts:62–79  ·  view source on GitHub ↗
(options?: NumberValidateOptions)

Source from the content-addressed store, hash-verified

60}
61
62export const numberValidateFn = (options?: NumberValidateOptions): ValidateFunction<number | undefined> => {
63 if (options?.min != null && options.max != null && options.min > options.max) {
64 throw Error('max must be >= min')
65 }
66
67 return (input: number | undefined): true | string => {
68 if (input == null) {
69 return true
70 }
71 if (options?.min != null && input < options.min) {
72 return `must be no less than ${options.min}`
73 }
74 if (options?.max != null && input > options.max) {
75 return `must be no more than ${options.max}`
76 }
77 return true
78 }
79}
80
81type URLValidateFnOptions = {
82 httpsRequired?: boolean

Callers 4

getInputFromUserFunction · 0.85
promptAndAddAttributeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected