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> PartialOrd for StringSizeRule<MIN, MAX>
impl<const MIN: usize, const MAX: usize> PartialOrd for StringSizeRule<MIN, MAX>
Source§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> StructuralPartialEq for StringSizeRule<MIN, MAX>
Auto Trait Implementations§
impl<const MIN: usize, const MAX: usize> Freeze for StringSizeRule<MIN, MAX>
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