pub enum Rule {
Show 30 variants
Required,
Present,
NotNull,
String,
Integer,
Numeric,
Boolean,
Array,
Min(f64),
Max(f64),
Size(f64),
Between(f64, f64),
Email,
Url,
Slug,
Uuid,
Alpha,
AlphaNumeric,
AlphaDash,
In(Vec<String>),
NotIn(Vec<String>),
StartsWith(String),
EndsWith(String),
Date,
After(NaiveDate),
Before(NaiveDate),
Confirmed,
Same(String),
Different(String),
Custom {
message: String,
check: Arc<dyn Fn(&Value) -> bool + Send + Sync>,
},
}Expand description
One validation rule.
Variants§
Required
Present, not null, and not empty.
Present
Present (may be null or empty).
NotNull
Not null when present.
String
A string (or a value that reads as one).
Integer
An integer.
Numeric
A number, integer or not.
Boolean
A boolean, or one of the strings a form sends for one.
Array
An array.
Min(f64)
At least this length: characters for a string, elements for an array, value for a number.
Max(f64)
At most this length, by the same measure as Rule::Min.
Size(f64)
Exactly this length.
Between(f64, f64)
Between these bounds, inclusive.
A plausible email address.
Url
An absolute http/https URL.
Slug
Letters, digits, - and _.
Uuid
A canonical UUID.
Alpha
ASCII letters only.
AlphaNumeric
ASCII letters and digits.
AlphaDash
Letters, digits, - and _.
In(Vec<String>)
One of these values.
NotIn(Vec<String>)
None of these values.
StartsWith(String)
Starts with this prefix.
EndsWith(String)
Ends with this suffix.
Date
A YYYY-MM-DD date.
After(NaiveDate)
A date on or after this one.
Before(NaiveDate)
A date on or before this one.
Confirmed
Equal to another field’s value — password_confirmation.
Same(String)
Equal to the named field’s value.
Different(String)
Different from the named field’s value.
Custom
Any predicate, with the message to use when it fails.