pub enum ValidationRule {
Show 13 variants
Required {
message: Option<String>,
},
MinLength {
value: usize,
message: Option<String>,
},
MaxLength {
value: usize,
message: Option<String>,
},
Pattern {
pattern: String,
message: Option<String>,
},
Email {
message: Option<String>,
},
Url {
message: Option<String>,
},
Min {
value: i64,
message: Option<String>,
},
Max {
value: i64,
message: Option<String>,
},
ContainsUppercase {
message: Option<String>,
},
ContainsLowercase {
message: Option<String>,
},
ContainsDigit {
message: Option<String>,
},
ContainsSpecial {
message: Option<String>,
},
MatchesField {
field: String,
message: Option<String>,
},
}Expand description
A validation rule for form fields.
Variants§
Required
Field is required.
MinLength
Minimum length.
MaxLength
Maximum length.
Pattern
Regular expression pattern.
Email format.
Url
URL format.
Min
Minimum numeric value.
Max
Maximum numeric value.
ContainsUppercase
Requires at least one uppercase letter.
ContainsLowercase
Requires at least one lowercase letter.
ContainsDigit
Requires at least one digit.
ContainsSpecial
Requires at least one special character.
MatchesField
Value must match another field.
Implementations§
Source§impl ValidationRule
impl ValidationRule
Sourcepub fn min_length(value: usize) -> Self
pub fn min_length(value: usize) -> Self
Create a min length rule.
Sourcepub fn max_length(value: usize) -> Self
pub fn max_length(value: usize) -> Self
Create a max length rule.
Sourcepub fn contains_uppercase() -> Self
pub fn contains_uppercase() -> Self
Create a contains uppercase rule.
Sourcepub fn contains_lowercase() -> Self
pub fn contains_lowercase() -> Self
Create a contains lowercase rule.
Sourcepub fn contains_digit() -> Self
pub fn contains_digit() -> Self
Create a contains digit rule.
Sourcepub fn contains_special() -> Self
pub fn contains_special() -> Self
Create a contains special character rule.
Sourcepub fn matches_field(field: impl Into<String>) -> Self
pub fn matches_field(field: impl Into<String>) -> Self
Create a matches field rule.
Trait Implementations§
Source§impl Clone for ValidationRule
impl Clone for ValidationRule
Source§fn clone(&self) -> ValidationRule
fn clone(&self) -> ValidationRule
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ValidationRule
impl Debug for ValidationRule
Source§impl<'de> Deserialize<'de> for ValidationRule
impl<'de> Deserialize<'de> for ValidationRule
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 ValidationRule
impl PartialEq for ValidationRule
Source§impl Serialize for ValidationRule
impl Serialize for ValidationRule
impl Eq for ValidationRule
impl StructuralPartialEq for ValidationRule
Auto Trait Implementations§
impl Freeze for ValidationRule
impl RefUnwindSafe for ValidationRule
impl Send for ValidationRule
impl Sync for ValidationRule
impl Unpin for ValidationRule
impl UnsafeUnpin for ValidationRule
impl UnwindSafe for ValidationRule
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.