Skip to main content

range_f64

Function range_f64 

Source
pub fn range_f64(
    lo: f64,
    hi: f64,
    msg: impl Into<String>,
) -> impl Fn(&str) -> Result<(), String>
Expand description

Parse the input as an f64 and require it to fall within lo..=hi.

Non-numeric or non-finite input fails with msg.

§Example

let field = FormField::new("Rate").validate(validators::range_f64(0.0, 1.0, "0.0–1.0 only"));