pub enum Validator {
Required,
Email,
Url,
MinLength(usize),
MaxLength(usize),
Min(f64),
Max(f64),
Pattern(String),
Range(f64, f64),
Custom(String),
}Expand description
Validator types for field validation
Variantsยง
Required
Url
MinLength(usize)
MaxLength(usize)
Min(f64)
Max(f64)
Pattern(String)
Range(f64, f64)
Custom(String)
Implementationsยง
Sourceยงimpl Validator
impl Validator
Sourcepub fn min_length(min: usize) -> Self
pub fn min_length(min: usize) -> Self
Create a minimum length validator
Sourcepub fn max_length(max: usize) -> Self
pub fn max_length(max: usize) -> Self
Create a maximum length validator
Sourcepub fn validate(&self, value: &FieldValue) -> Result<(), String>
pub fn validate(&self, value: &FieldValue) -> Result<(), String>
Validate a value against this validator
Sourcepub fn description(&self) -> String
pub fn description(&self) -> String
Get a human-readable description of this validator
Sourcepub fn custom_name(&self) -> Option<&str>
pub fn custom_name(&self) -> Option<&str>
Get the custom validator name if this is a custom validator
Trait Implementationsยง
Sourceยงimpl<'de> Deserialize<'de> for Validator
impl<'de> Deserialize<'de> for Validator
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>,
Deserialize this value from the given Serde deserializer. Read more
Sourceยงimpl PartialEq for Validator
impl PartialEq for Validator
impl StructuralPartialEq for Validator
Auto Trait Implementationsยง
impl Freeze for Validator
impl RefUnwindSafe for Validator
impl Send for Validator
impl Sync for Validator
impl Unpin for Validator
impl UnsafeUnpin for Validator
impl UnwindSafe for Validator
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
Mutably borrows from an owned value. Read more
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<T> FromFormData for Twhere
T: DeserializeOwned,
impl<T> FromFormData for Twhere
T: DeserializeOwned,
Sourceยงfn from_event(ev: &Event) -> Result<T, FromFormDataError>
fn from_event(ev: &Event) -> Result<T, FromFormDataError>
Tries to deserialize the data, given only the
submit event.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>
Converts
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>
Converts
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 moreSourceยงimpl<T> SerializableKey for T
impl<T> SerializableKey for T
Sourceยงimpl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Sourceยงfn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Sourceยงfn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.