MCPcopy Create free account
hub / github.com/github/gh-aw / IsCronExpression

Function IsCronExpression

pkg/parser/schedule_cron_detection.go:140–158  ·  view source on GitHub ↗

IsCronExpression checks if the input looks like a valid cron expression A valid cron expression has exactly 5 fields (minute, hour, day of month, month, day of week)

(input string)

Source from the content-addressed store, hash-verified

138// IsCronExpression checks if the input looks like a valid cron expression
139// A valid cron expression has exactly 5 fields (minute, hour, day of month, month, day of week)
140func IsCronExpression(input string) bool {
141 // A cron expression has exactly 5 fields
142 fields := strings.Fields(input)
143 if len(fields) != 5 {
144 cronDetectionLog.Printf("Input is not a cron expression (expected 5 fields, got %d): %q", len(fields), input)
145 return false
146 }
147
148 // Each field should match cron syntax (numbers, *, /, -, ,)
149 for _, field := range fields {
150 if !cronFieldPattern.MatchString(field) {
151 cronDetectionLog.Printf("Cron field %q contains invalid characters in expression: %q", field, input)
152 return false
153 }
154 }
155
156 cronDetectionLog.Printf("Input recognized as valid cron expression: %q", input)
157 return true
158}

Calls 1

PrintfMethod · 0.45