Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Range

Validate a value is within a range.

#![allow(unused)]
fn main() {
extern crate fortifier;

use fortifier::Validate;

#[derive(Validate)]
struct Object {
    #[validate(range(exclusive_min = 0.0, max = 100.0))]
    height: f64,
}
}

Types

Boolean

Number

Character

String

Other

Options

min

The value should be equal to or greater than the specified expression.

#![allow(unused)]
fn main() {
extern crate fortifier;

use fortifier::Validate;

#[derive(Validate)]
struct Object {
    #[validate(range(min = 0.0))]
    height: f64
}
}

max

The value should be equal to or less than the specified expression.

#![allow(unused)]
fn main() {
extern crate fortifier;

use fortifier::Validate;

#[derive(Validate)]
struct Object {
    #[validate(range(max = 100.0))]
    height: f64
}
}

exclusive_min

The value should be greater than the specified expression.

#![allow(unused)]
fn main() {
extern crate fortifier;

use fortifier::Validate;

#[derive(Validate)]
struct Object {
    #[validate(range(exclusive_min = 0.0))]
    height: f64
}
}

exclusive_max

The value should be less than the specified expression.

#![allow(unused)]
fn main() {
extern crate fortifier;

use fortifier::Validate;

#[derive(Validate)]
struct Object {
    #[validate(range(exclusive_max = 100.0))]
    height: f64
}
}