pub fn validate_cron(expr: &str) -> ValidationResultExpand description
A cron expression parses with the same parser the controller uses at runtime, so bad expressions are rejected at apply time, not at first reconcile (ADR §4.1).
croner 2.x does not implement Jenkins-style H. Since kopiur resolves H
deterministically in crate::jitter::substitute_h (not in the parser), we
substitute every H field with the fixed placeholder 0 purely to validate the
expression’s shape here. The real H spread is produced at scheduling time.
use kopiur_api::validate::validate_cron;
use kopiur_api::ValidationError;
// Valid 5-field crons pass — including Jenkins-style `H` (resolved later).
assert!(validate_cron("0 2 * * *").is_ok());
assert!(validate_cron("H 2 * * *").is_ok());
// Garbage is rejected at apply time, not at first reconcile (ADR §4.1).
assert!(matches!(
validate_cron("not a cron"),
Err(ValidationError::InvalidCron { .. }),
));