seventy 0.1.0

Newtype sanitization and validation
Documentation

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 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());