use rfc 5322 email regex

This commit is contained in:
2025-07-19 22:09:07 +02:00
parent 496d5bdb2b
commit deff81d2ff

View File

@@ -86,8 +86,9 @@ pub enum UserEmailError {
Empty,
}
static USER_EMAIL_REGEX: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"^[^@]+@[^@]+\.[^@]+$").expect("Email regex"));
static USER_EMAIL_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r#"^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$"#).expect("Email regex")
});
impl UserEmail {
pub fn new(raw: &str) -> Result<Self, UserEmailError> {