Overview
Seventy is a simple newtype sanitizer and validator.
There is no error handling. If you need to know why the newtype couldn't be created, this crate isn't for you.
Usage
use ;
;
assert_eq!;
assert!;
Seventy is a simple newtype sanitizer and validator.
There is no error handling. If you need to know why the newtype couldn't be created, this crate isn't for you.
use seventy::{
builtins::{compare::*, string::*},
seventy, Newtype,
};
#[seventy(
sanitize(trim),
validate(alphanumeric, length::chars(within(5..=20))),
)]
pub struct Username(String);
assert_eq!(
Username::try_new(" username ").unwrap().into_inner(),
"username"
);
assert!(Username::try_new(" u$ername ").is_err());