pub fn validate_email_with_name(s: &str) -> Result<(), ValidationError>Expand description
Accepts both a bare email (user@host.tld) and the RFC 5322
display-name form
("Display Name" <user@host.tld> or Display Name <user@host.tld>).
Useful for From: / To: / Cc: header values where operators
may type the human-friendly form. Internally splits via
crate::email::parseaddr and forwards the address portion to
validate_email.
ⓘ
use rustango::validators::validate_email_with_name;
assert!(validate_email_with_name("alice@example.com").is_ok());
assert!(validate_email_with_name("Alice <alice@example.com>").is_ok());
assert!(validate_email_with_name("\"Alice C.\" <alice@example.com>").is_ok());
assert!(validate_email_with_name("not an email").is_err());§Errors
ValidationError { code: "invalid_email", ... } if the email
portion (after stripping the optional display name) doesn’t
pass validate_email.
Gated on the email feature since the implementation routes
through crate::email::parseaddr. Operators on a non-email
build can still parse + validate manually by hand-rolling
the Name <addr> split themselves and passing the address
through validate_email.