pub struct lowercase;Expand description
Sanitizer converts to lowercase. Validator checks if only lowercase.
§Examples
An example of the lowercase validator.
use seventy::{builtins::string::*, seventy, Newtype};
#[seventy(sanitize(lowercase))]
pub struct SearchQuery(String);
// Converts uppercase characters to lowercase.
assert_eq!(
SearchQuery::try_new("What is the SeVeNTy crate?!")
.unwrap()
.into_inner(),
"what is the seventy crate?!"
);An example of the lowercase sanitizer.
use seventy::{builtins::string::*, seventy, Newtype};
#[seventy(validate(lowercase))]
pub struct LowercaseString(String);
// Successfully constructed because the string is only lowercase.
assert!(LowercaseString::try_new("whisper").is_ok());
// Unsuccessfully constructed because the string is not only lowercase.
assert!(LowercaseString::try_new("Whisper").is_err());Trait Implementations§
Auto Trait Implementations§
impl Freeze for lowercase
impl RefUnwindSafe for lowercase
impl Send for lowercase
impl Sync for lowercase
impl Unpin for lowercase
impl UnwindSafe for lowercase
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