looksValid returns true if the input looks like it might be valid
(input string)
| 521 | |
| 522 | // looksValid returns true if the input looks like it might be valid |
| 523 | func 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 | } |
no test coverage detected