Struct validus::vstrext::StringSizeRule
source · pub struct StringSizeRule<const MIN: usize, const MAX: usize>;
Expand description
A rule that checks the size of a string.
MIN
and MAX
are inclusive number of bytes.
Example
use validus::prelude::*;
// inclusive
type PasswordRule = StringSizeRule<8, 32>;
// too short
let pw = "1234".validate::<PasswordRule>();
assert!(pw.is_err());
// 4 * 8 + 1 = 33 bytes (too long)
let pw = "aaaabbbbccccddddeeeeffffgggghhhhi".validate::<PasswordRule>();
assert!(pw.is_err());
// good
let pw = "12345678".validate::<PasswordRule>();
assert!(pw.is_ok());
Trait Implementations§
source§impl<const MIN: usize, const MAX: usize> Clone for StringSizeRule<MIN, MAX>
impl<const MIN: usize, const MAX: usize> Clone for StringSizeRule<MIN, MAX>
source§fn clone(&self) -> StringSizeRule<MIN, MAX>
fn clone(&self) -> StringSizeRule<MIN, MAX>
Returns a copy 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<const MIN: usize, const MAX: usize> Default for StringSizeRule<MIN, MAX>
impl<const MIN: usize, const MAX: usize> Default for StringSizeRule<MIN, MAX>
source§fn default() -> StringSizeRule<MIN, MAX>
fn default() -> StringSizeRule<MIN, MAX>
Returns the “default value” for a type. Read more
source§impl<const MIN: usize, const MAX: usize> Ord for StringSizeRule<MIN, MAX>
impl<const MIN: usize, const MAX: usize> Ord for StringSizeRule<MIN, MAX>
source§fn cmp(&self, other: &StringSizeRule<MIN, MAX>) -> Ordering
fn cmp(&self, other: &StringSizeRule<MIN, MAX>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<const MIN: usize, const MAX: usize> PartialEq<StringSizeRule<MIN, MAX>> for StringSizeRule<MIN, MAX>
impl<const MIN: usize, const MAX: usize> PartialEq<StringSizeRule<MIN, MAX>> for StringSizeRule<MIN, MAX>
source§fn eq(&self, other: &StringSizeRule<MIN, MAX>) -> bool
fn eq(&self, other: &StringSizeRule<MIN, MAX>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<const MIN: usize, const MAX: usize> PartialOrd<StringSizeRule<MIN, MAX>> for StringSizeRule<MIN, MAX>
impl<const MIN: usize, const MAX: usize> PartialOrd<StringSizeRule<MIN, MAX>> for StringSizeRule<MIN, MAX>
source§fn partial_cmp(&self, other: &StringSizeRule<MIN, MAX>) -> Option<Ordering>
fn partial_cmp(&self, other: &StringSizeRule<MIN, MAX>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl<const MIN: usize, const MAX: usize> ValidateString for StringSizeRule<MIN, MAX>
impl<const MIN: usize, const MAX: usize> ValidateString for StringSizeRule<MIN, MAX>
impl<const MIN: usize, const MAX: usize> Copy for StringSizeRule<MIN, MAX>
impl<const MIN: usize, const MAX: usize> Eq for StringSizeRule<MIN, MAX>
impl<const MIN: usize, const MAX: usize> StructuralEq for StringSizeRule<MIN, MAX>
impl<const MIN: usize, const MAX: usize> StructuralPartialEq for StringSizeRule<MIN, MAX>
Auto Trait Implementations§
impl<const MIN: usize, const MAX: usize> RefUnwindSafe for StringSizeRule<MIN, MAX>
impl<const MIN: usize, const MAX: usize> Send for StringSizeRule<MIN, MAX>
impl<const MIN: usize, const MAX: usize> Sync for StringSizeRule<MIN, MAX>
impl<const MIN: usize, const MAX: usize> Unpin for StringSizeRule<MIN, MAX>
impl<const MIN: usize, const MAX: usize> UnwindSafe for StringSizeRule<MIN, MAX>
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