MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / isValidRangeOrNumber

Function isValidRangeOrNumber

packages/server/src/services/schedule/utils.ts:45–58  ·  view source on GitHub ↗
(s: string, min: number, max: number)

Source from the content-addressed store, hash-verified

43
44 // Returns true if s is a valid integer in [min, max] or a valid range "start-end"
45 const isValidRangeOrNumber = (s: string, min: number, max: number): boolean => {
46 const dashIdx = s.indexOf('-')
47 if (dashIdx !== -1) {
48 const startStr = s.slice(0, dashIdx)
49 const endStr = s.slice(dashIdx + 1)
50 if (!/^\d+$/.test(startStr) || !/^\d+$/.test(endStr)) return false
51 const start = parseInt(startStr, 10)
52 const end = parseInt(endStr, 10)
53 return start >= min && start <= max && end >= min && end <= max && start <= end
54 }
55 if (!/^\d+$/.test(s)) return false
56 const n = parseInt(s, 10)
57 return n >= min && n <= max
58 }
59
60 // Validate a single cron field: supports *, numbers, ranges (n-m), steps (*/s, n/s, n-m/s), and comma-separated lists.
61 // When `allowL` is true, also accepts the standalone `L` token (used for the day-of-month field to mean "last day of month").

Callers 1

validateCronFieldFunction · 0.85

Calls 1

testMethod · 0.80

Tested by

no test coverage detected