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