Why is a TLD as domain accepted under RFC 822/Apache-commons validations?

Viewed 66

According to the Apache docs, their email validation respects the RFC 822 specification.

EmailValidator provides email address validation according to RFC 822 standards. source

However when running some tests locally I found that some TLD's are accepted as a domain.

test@test      //invalid
test@test.com  //valid
test@com       //valid
test@comm      //invalid
test@amsterdam //valid
test@brussels  //valid

I thought I read somewhere in the RFC that <local>@<domain> is a valid e-mail address but highly discouraged to use (..and thus should be considered invalid?). So I get that test@test will not be valid, however test@amsterdam is, because .amsterdam is a valid gTLD.

Not sure if this is a bug or if this is intended. From their implementation and documentation it is unclear what should be valid, and if it is 100% comform the RFC 822 specification.


class Test {
    EmailValidator validator = EmailValidator.getInstance(false, true);

    @ParameterizedTest
    @ValueSource(strings = {
            "test@test",
            "test@test.com",
            "test@com",
            "test@comm",
            "test@amsterdam",
            "test@brussels"
    })
    void emails(String email) {
        System.out.printf("%-20s valid? %s%n", email, validator.isValid(email));
    }
}

What I also don't seem to get is what the parameters allowLocal and allowTld in the EmailValidator constructor do

0 Answers
Related