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

fix: improve email validation using net/mail package #60

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sniperwolf
Copy link

@sniperwolf sniperwolf commented Feb 4, 2025

📧 Improve email validation using net/mail instead of regex

Context

Currently, our email validation is using a regex pattern that doesn't fully support all valid email separators according to RFC 5322. This PR replaces it with Go's built-in net/mail.ParseAddress which properly handles all valid email characters.

Changes

  • Removed regex-based validation
  • Added net/mail package for proper RFC 5322 compliant validation
  • Updated tests to cover more edge cases

Before

The current regex validation fails with valid email addresses containing special characters like +, {, }, ~, * etc.

Example of a valid email that was incorrectly rejected:

validemail+with_valid-separator{like}~these*[email protected]

After

Using net/mail.ParseAddress, we now correctly validate emails containing all RFC 5322 compliant characters:

validemail+with_valid-separator{like}~these*[email protected]

This change makes our email validation more robust and standards-compliant while actually simplifying the code by leveraging Go's standard library.

Would love to get this merged to improve our validation capabilities! Let me know if you'd like any changes or have questions. 🚀

@sniperwolf sniperwolf requested a review from a team as a code owner February 4, 2025 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant