Length
Validate the length of a string or iterable.
#![allow(unused)]
fn main() {
extern crate fortifier;
use fortifier::Validate;
#[derive(Validate)]
struct User {
#[validate(length(min = 1, max = 256))]
name: String
}
}
Types
String
Validate the amount of characters (chars) in a string.
Iterable
[T](slice)[T; N](array)BTreeSetBTreeMapHashSetHashMapIndexSet(requires featureindexmap)IndexMap(requires featureindexmap)LinkedListVecVecDeque
Validate the amount of entries in an iterable.
Options
equal
The length should be equal to the specified expression.
#![allow(unused)]
fn main() {
extern crate fortifier;
use fortifier::Validate;
#[derive(Validate)]
struct User {
#[validate(length(equal = 2))]
country_code: String
}
}
min
The length should be equal to or greater than the specified expression.
#![allow(unused)]
fn main() {
extern crate fortifier;
use fortifier::Validate;
#[derive(Validate)]
struct User {
#[validate(length(min = 1))]
name: String
}
}
max
The length should be equal to or less than the specified expression.
#![allow(unused)]
fn main() {
extern crate fortifier;
use fortifier::Validate;
#[derive(Validate)]
struct User {
#[validate(length(max = 256))]
name: String
}
}