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

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

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
}
}