Expand description
Combinators for composing Validators.
And, Or, and Not build compound rules from simpler ones, entirely
at the type level. Because they are themselves Validators, they nest:
And<A, Or<B, C>> is a valid rule.
And and Or require their two sub-rules to share one error type, which is
the case for every built-in rule (all report
ValidationError). Not works with any sub-rule and reports its own
ValidationError.
§Examples
use type_lib::combinator::And;
use type_lib::rules::{Ascii, NonEmpty};
use type_lib::Refined;
// A token: non-empty and ASCII-only.
type Token<'a> = Refined<&'a str, And<NonEmpty, Ascii>>;
assert!(Token::new("abc123").is_ok());
assert!(Token::new("").is_err()); // fails NonEmpty
assert!(Token::new("café").is_err()); // fails Ascii