Stranger6667/jsonschema-rs

Is it expected that email validation is a bit incomplete?

qrilka opened this issue · 3 comments

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

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;