Fix email validation to reject TLD-only domains like user@com#380
Fix email validation to reject TLD-only domains like user@com#380Lucas-BRT wants to merge 1 commit intoKeats:masterfrom
Conversation
|
Technically user@com can be a valid email. The current regex matches the HTML5 email regex that does allow it |
|
Although HTML5 allows email addresses like user@com with its internal regex, this does not reflect the stricter rules required by actual email validation standards. HTML5 validation, as shown in W3Schools, does not allow user@com. Allowing this could lead to issues with DNS systems and other technical risks, as outlined in ICANN's guide on dotless domains. For more robust validation, stricter rules should be applied. RFC 5321: https://datatracker.ietf.org/doc/html/rfc5321 RFC 5322: https://datatracker.ietf.org/doc/html/rfc5322 W3Schools: https://www.w3schools.com/tags/att_input_pattern.asp ICANN Guide: https://www.icann.org/en/announcements/details/new-gtld-dotless-domain-names-prohibited-30-8-2013-en |
|
thoughts on just making this another type like email_strict or email_domain |

This pull request enhances the email validation logic in
validator/src/validation/email.rsto ensure stricter compliance with domain validation rules. It also updates the corresponding test cases to reflect these changes and adds new tests to cover edge cases.Email Validation Logic Updates:
validate_domain_partto reject email addresses with top-level domains (e.g.,user@com) by requiring at least one dot in the domain part. This ensures stricter validation of domain structures.Test Case Updates:
abc@baras invalid, aligning with the stricter domain validation rules.test_user_at_com_failsto validate thatuser@comis correctly identified as an invalid email address.validator_derive_tests/tests/email.rsto ensure that custom implementations for email validation also reject top-level domain-only email addresses. This includes detailed error assertions to verify the validation logic.