Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it expected that email validation is a bit incomplete? #471

Open
qrilka opened this issue Apr 4, 2024 · 1 comment
Open

Is it expected that email validation is a bit incomplete? #471

qrilka opened this issue Apr 4, 2024 · 1 comment

Comments

@qrilka
Copy link

qrilka commented Apr 4, 2024

In

fn is_valid_email(email: &str) -> bool {
if let Some('.') = email.chars().next() {
// dot before local part is not valid
return false;
}
// This loop exits early if it finds `@`.
// Therefore, match arms examine only the local part
for (a, b) in email.chars().zip(email.chars().skip(1)) {
match (a, b) {
// two subsequent dots inside local part are not valid
// dot after local part is not valid
('.', '.') | ('.', '@') => return false,
// The domain part is not validated for simplicity
(_, '@') => return true,
(_, _) => continue,
}
}
false
}
I see that email validation doesn't check for non-printable characters and explicitly says that domain validation is not done

@Stranger6667
Copy link
Owner

That is deliberately simplistic, but I am open to extending it. From the spec:

When the implementation is configured for assertion behavior, it:
SHOULD provide an implementation-specific best effort validation for each format attribute defined below;
MAY choose to implement validation of any or all format attributes as a no-op by always producing a validation result of true;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants