Skip to main content

validate_range

Function validate_range 

Source
pub fn validate_range<T: PartialOrd + Display + Copy>(
    value: &T,
    min: Option<T>,
    max: Option<T>,
    path: &[PathSegment],
    errors: &mut ValidationErrors,
)
Expand description

Validate that the value is within the specified numeric range.

  • min: Minimum value (inclusive). None means no lower bound.
  • max: Maximum value (inclusive). None means no upper bound.

Works with all Rust numeric types: i8, i16, i32, i64, i128, u8, u16, u32, u64, u128, f32, f64, isize, usize. Validate that the value is within the specified numeric range.

Works with all Rust numeric types including i128/u128. Uses Display for error message formatting instead of Into<serde_json::Value> to avoid trait bound issues with 128-bit integers.