Function rocket::form::validate::range

source ·
pub fn range<'v, V, R>(value: &V, range: R) -> Result<'v, ()>
where V: TryInto<isize> + Copy, R: RangeBounds<isize>,
Expand description

Integer range validator: succeeds when an integer value is within a range.

The value must be an integer type that implement TryInto<isize> + Copy. On error, returns an OutOfRange error.

§Example

use rocket::form::FromForm;

#[derive(FromForm)]
struct Foo {
    #[field(validate = range(0..))]
    non_negative: isize,
    #[field(validate = range(18..=130))]
    maybe_adult: u8,
}