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
DateTime(requires featurechrono)NaiveDate(requires featurechrono)NaiveDateTime(requires featurechrono)NaiveTime(requires featurechrono)TimeDelta(requires featurechrono)Decimal(requires featuredecimal)Uuid(requires featureuuid)
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
}
}