Hacker News new | ask | show | jobs
by cyberbanjo 1100 days ago
I was surprised to learn the extent of what is a valid local-part (something+else in your example) of an email. Can have two dots in sequence if the local-part is quoted, and support for non alphanumeric characters like !#$%&'*+-/=?^_`{|}~; if the local-part is quoted, comments with parentheses. And it could be case sensitive.
1 comments

We have the following validation:

    let form_email: Option::<String> = /* ... */;
    
    match form_email {
        Some(email) if !email.is_empty() => {
            // ... send email with validation link
        },
        _ => {
            // report missing email
        }
    }

If you (can) click the validation link it's a valid email. If not... it's invalid. Saves me the trouble of debugging all the regexes.