Skip to main content

one_of

Function one_of 

Source
pub fn one_of(
    allowed: &[&str],
    msg: impl Into<String>,
) -> impl Fn(&str) -> Result<(), String>
Expand description

Require the input to be one of the allowed values (exact, case-sensitive).

ยงExample

let field = FormField::new("Role")
    .validate(validators::one_of(&["admin", "user"], "admin or user"));