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 + Sync + Send>,
},
}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.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Rule
impl !UnwindSafe for Rule
impl Freeze for Rule
impl Send for Rule
impl Sync for Rule
impl Unpin for Rule
impl UnsafeUnpin for Rule
Blanket Implementations§
impl<T> Actor for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more