pub struct DateHandler;Expand description
Date validation and canonicalization handler
Supports multiple input date formats:
- YYYY-MM-DD: ISO 8601 standard format (e.g., “2025-12-25”)
- YYYYMMDD: Compact format without separators (e.g., “20251225”)
- YYYY-DDD: Day-of-year format (e.g., “2025-359” for December 25th)
All valid input formats are canonicalized to the format specified in the schema configuration, ensuring consistent representation across the system.
Implementations§
Source§impl DateHandler
impl DateHandler
Sourcepub fn validate_and_canonicalize(
value: &str,
canonical_format: &str,
field_name: &str,
) -> Result<String>
pub fn validate_and_canonicalize( value: &str, canonical_format: &str, field_name: &str, ) -> Result<String>
Validate and canonicalize a date value according to schema requirements
This method performs comprehensive date validation:
- Attempts to parse the input using multiple supported formats
- Validates that the date is actually valid (e.g., no February 30th)
- Converts to the canonical format specified in the schema
§Arguments
value- The date string to validate (in any supported format)canonical_format- Target format for canonicalization (“%Y%m%d” or “%Y-%m-%d”)field_name- Name of the field being validated (for error messages)
§Returns
Ok(String)- The date in canonical formatErr(anyhow::Error)- Invalid date format or impossible date
Auto Trait Implementations§
impl Freeze for DateHandler
impl RefUnwindSafe for DateHandler
impl Send for DateHandler
impl Sync for DateHandler
impl Unpin for DateHandler
impl UnsafeUnpin for DateHandler
impl UnwindSafe for DateHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more