pub struct IntHandler;Expand description
Integer validation handler
Validates and canonicalizes integer values with optional range constraints.
Implementations§
Source§impl IntHandler
impl IntHandler
Sourcepub fn validate_and_canonicalize(
value: &str,
range: Option<&[i64; 2]>,
field_name: &str,
) -> Result<String>
pub fn validate_and_canonicalize( value: &str, range: Option<&[i64; 2]>, field_name: &str, ) -> Result<String>
Validate and canonicalize an integer value with optional range checking
This method performs comprehensive integer validation:
- Parses the input string as a signed 64-bit integer
- Validates the value is within the specified range (if configured)
- Returns the canonical string representation of the integer
§Arguments
value- The string value to validate as an integerrange- Optional [min, max] range constraint (inclusive bounds)field_name- Name of the field being validated (for error messages)
§Returns
Ok(String)- The canonical string representation of the valid integerErr(anyhow::Error)- Invalid integer format or out of range
§Range Validation
When a range is specified as [min, max], both bounds are inclusive:
[0, 100]allows values from 0 to 100 (including 0 and 100)[1, 10]allows values from 1 to 10 (including 1 and 10)- No range means any valid integer is accepted
Auto Trait Implementations§
impl Freeze for IntHandler
impl RefUnwindSafe for IntHandler
impl Send for IntHandler
impl Sync for IntHandler
impl Unpin for IntHandler
impl UnsafeUnpin for IntHandler
impl UnwindSafe for IntHandler
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