#[non_exhaustive]pub enum Rule {
Required,
RequiredOn(Mode),
MinLength(usize),
MaxLength(usize),
Email,
Numeric,
Url,
Date,
Unique,
}Expand description
A single rule applied to one field’s submitted value. Serde-serialisable so
a descriptor (later YAML) can author rules by name (required, email,
max_length, …).
Non-exhaustive: rules are added as field types need them, so match with a _
arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Required
Non-empty after trimming, in every mode.
RequiredOn(Mode)
Non-empty after trimming, in the given mode only.
MinLength(usize)
At least n characters. Skipped when empty, so pair it with Required
to forbid blanks.
MaxLength(usize)
At most n characters.
A syntactically plausible email address. Skipped when empty.
Numeric
Parses as a number (integer or decimal). Skipped when empty.
Url
A syntactically valid absolute URL with a host. Skipped when empty.
Date
A calendar date, YYYY-MM-DD. Skipped when empty.
Unique
The value must not already exist in this field’s column of the target table. On update, the edited row is ignored.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Rule
impl<'de> Deserialize<'de> for Rule
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Rule
impl RefUnwindSafe for Rule
impl Send for Rule
impl Sync for Rule
impl Unpin for Rule
impl UnsafeUnpin for Rule
impl UnwindSafe for Rule
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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