Skip to main content

validate_timezone

Function validate_timezone 

Source
pub fn validate_timezone(name: Option<&str>) -> ValidationResult
Expand description

Validate an optional IANA timezone name against the same chrono-tz database the controller uses at scheduling time, so a typo (e.g. America/Chicgo) is rejected at apply time rather than silently resolving to UTC at the next reconcile. None (use the controller default) is always valid.

use kopiur_api::validate::validate_timezone;

assert!(validate_timezone(None).is_ok());
assert!(validate_timezone(Some("America/Chicago")).is_ok());
assert!(validate_timezone(Some("UTC")).is_ok());
assert!(validate_timezone(Some("America/Chicgo")).is_err());