fix: improve email validation using net/mail package #60
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📧 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
net/mail
package for proper RFC 5322 compliant validationBefore
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. 🚀