Skip to main content

Module validators

Module validators 

Source
Expand description

Built-in field validator constructors (required / length / email / range / regex / one-of).

Each function returns a closure suitable for FormField::validate or Validator::new. All matchers are handwritten — there is no regex or email-parsing dependency.

Functions§

email
Accept a plausibly-formed email address.
max_len
Require at most n characters (counted as Unicode scalar values).
min_len
Require at least n characters (counted as Unicode scalar values).
one_of
Require the input to be one of the allowed values (exact, case-sensitive).
range_f64
Parse the input as an f64 and require it to fall within lo..=hi.
range_i64
Parse the input as an i64 and require it to fall within lo..=hi.
regex
Match the input against a minimal glob-style pattern.
required
Reject empty or whitespace-only input.