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

Function looksValid

pkg/parser/schedule_parser_fuzz_test.go:523–564  ·  view source on GitHub ↗

looksValid returns true if the input looks like it might be valid

(input string)

Source from the content-addressed store, hash-verified

521
522// looksValid returns true if the input looks like it might be valid
523func looksValid(input string) bool {
524 input = strings.TrimSpace(strings.ToLower(input))
525
526 // Empty is not valid
527 if input == "" {
528 return false
529 }
530
531 // Check if it's a cron expression (5 fields)
532 fields := strings.Fields(input)
533 if len(fields) == 5 {
534 // Could be a valid cron expression
535 return true
536 }
537
538 // Check for valid patterns
539 validPrefixes := []string{
540 "daily",
541 "weekly on",
542 "monthly on",
543 "every 5m",
544 "every 10m",
545 "every 15m",
546 "every 30m",
547 "every 1h",
548 "every 2h",
549 "every 5 minutes",
550 "every 10 minutes",
551 "every 15 minutes",
552 "every 30 minutes",
553 "every 1 hour",
554 "every 2 hours",
555 }
556
557 for _, prefix := range validPrefixes {
558 if strings.HasPrefix(input, prefix) {
559 return true
560 }
561 }
562
563 return false
564}

Callers 1

FuzzScheduleParserFunction · 0.85

Calls 1

ToLowerMethod · 0.80

Tested by

no test coverage detected