MCPcopy Index your code
hub / github.com/simstudioai/sim / hasValidScheduleConfig

Function hasValidScheduleConfig

apps/sim/lib/workflows/schedules/validation.ts:38–76  ·  view source on GitHub ↗

* Check if a schedule type has valid configuration * Uses raw block values to avoid false positives from default parsing

(scheduleType: string | undefined, block: BlockState)

Source from the content-addressed store, hash-verified

36 * Uses raw block values to avoid false positives from default parsing
37 */
38function hasValidScheduleConfig(scheduleType: string | undefined, block: BlockState): boolean {
39 switch (scheduleType) {
40 case 'minutes': {
41 const rawValue = getSubBlockValue(block, 'minutesInterval')
42 const numValue = Number(rawValue)
43 return !!rawValue && !Number.isNaN(numValue) && numValue >= 1 && numValue <= 1440
44 }
45 case 'hourly': {
46 const rawValue = getSubBlockValue(block, 'hourlyMinute')
47 const numValue = Number(rawValue)
48 return rawValue !== '' && !Number.isNaN(numValue) && numValue >= 0 && numValue <= 59
49 }
50 case 'daily': {
51 const rawTime = getSubBlockValue(block, 'dailyTime')
52 return isValidTimeValue(rawTime)
53 }
54 case 'weekly': {
55 const rawDay = getSubBlockValue(block, 'weeklyDay')
56 const rawTime = getSubBlockValue(block, 'weeklyDayTime')
57 return !!rawDay && isValidTimeValue(rawTime)
58 }
59 case 'monthly': {
60 const rawDay = getSubBlockValue(block, 'monthlyDay')
61 const rawTime = getSubBlockValue(block, 'monthlyTime')
62 const dayNum = Number(rawDay)
63 return (
64 !!rawDay &&
65 !Number.isNaN(dayNum) &&
66 dayNum >= 1 &&
67 dayNum <= 31 &&
68 isValidTimeValue(rawTime)
69 )
70 }
71 case 'custom':
72 return !!getSubBlockValue(block, 'cronExpression')
73 default:
74 return false
75 }
76}
77
78/**
79 * Get human-readable error message for missing schedule configuration

Callers 1

validateScheduleBlockFunction · 0.85

Calls 2

getSubBlockValueFunction · 0.90
isValidTimeValueFunction · 0.85

Tested by

no test coverage detected