pub enum Rule {
Show 25 variants
Required,
Nullable,
String,
Integer,
Numeric,
Boolean,
Email,
Url,
Min(f64),
Max(f64),
Between(f64, f64),
Size(f64),
In(Vec<String>),
NotIn(Vec<String>),
Confirmed,
Same(String),
Different(String),
Alpha,
AlphaNum,
AlphaDash,
StartsWith(Vec<String>),
EndsWith(Vec<String>),
Date,
Uuid,
Array,
}Expand description
One validation rule, with its parameters already parsed.
This is the single internal representation: the string parser and the builder are two front doors onto the same enum.
Variants§
Required
The field must be present and not blank.
Nullable
An explicit null is allowed, and skips the remaining rules.
String
Integer
Numeric
Boolean
Url
Min(f64)
Minimum length for a string, value for a number, item count for an array.
Max(f64)
Maximum length for a string, value for a number, item count for an array.
Between(f64, f64)
Inclusive range, measured the same way as Rule::Min.
Size(f64)
Exact length, value, or item count.
In(Vec<String>)
NotIn(Vec<String>)
Confirmed
A <field>_confirmation field must be present and equal.
Same(String)
Must equal another field.
Different(String)
Must differ from another field.
Alpha
AlphaNum
AlphaDash
StartsWith(Vec<String>)
EndsWith(Vec<String>)
Date
A YYYY-MM-DD calendar date.
Uuid
Array
Implementations§
Source§impl Rule
impl Rule
Sourcepub fn name(&self) -> &'static str
pub fn name(&self) -> &'static str
The name this rule is written as in the string syntax, which is also the key used to look up its message and any per-field override.
pub fn required() -> Rules
pub fn nullable() -> Rules
pub fn string() -> Rules
pub fn integer() -> Rules
pub fn numeric() -> Rules
pub fn boolean() -> Rules
pub fn email() -> Rules
pub fn url() -> Rules
pub fn min(bound: impl Into<f64>) -> Rules
pub fn max(bound: impl Into<f64>) -> Rules
pub fn between(low: impl Into<f64>, high: impl Into<f64>) -> Rules
pub fn size(exact: impl Into<f64>) -> Rules
Sourcepub fn one_of<S: Into<String>>(values: impl IntoIterator<Item = S>) -> Rules
pub fn one_of<S: Into<String>>(values: impl IntoIterator<Item = S>) -> Rules
The builder spelling of in:a,b,c; in is a Rust keyword.