Simple validation with error reporting, inspired by validator. Provide users with targeted, actionable error messages.
I'd love to see this functionality become a part of validator. Until then, unless you specifically need span-based validation, just use validator. This crate only exists to provide better error messages than possible with just validator.
use span_validator::email::{Error, ErrorSpan, validate_email};
// invalid"@example.com
// ^
assert_eq!(
validate_email(r#"invalid"@example.com"#),
Err(ErrorSpan { error_type: Error::InvalidUserCharacter, span: 7..7 })
);