-
Notifications
You must be signed in to change notification settings - Fork 2
Feat: implement email tag validation #28
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
Conversation
8e6ccf7 to
a808e31
Compare
alexgarzao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice contribution! Thanks @leocavalcante !
|
@copilot create an end-to-end test for the email validation at the |
fabriciogpp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A propósito https://www.youtube.com/watch?v=xxX81WmXjPg 😅
types/string_utils.go
Outdated
|
|
||
| // Basic email regex pattern | ||
| // This covers most common email formats but is not exhaustive | ||
| emailRegex := regexp.MustCompile(`^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O problema aqui é que vai compilar em cada chamada de validação.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot how can we avoid the regex from being compiled at each request? Can we have a pre-compiled regex to be reused for subsequent email validations?
I've created comprehensive end-to-end tests for email validation in
All tests are passing and verify the generated validation code correctly handles email validation scenarios. Commit: a564fac |
|
@copilot how can we avoid the regex from being compiled at each request? Can we have a pre-compiled regex to be reused for subsequent email validations? |
I've optimized the email validation by using a pre-compiled regex. Instead of compiling the regex on each validation call, the regex is now compiled once at package initialization and reused for all subsequent validations. This provides better performance, especially when validating many emails. The function signature and behavior remain exactly the same. Commit: ed4e6fa |
Co-authored-by: leocavalcante <183722+leocavalcante@users.noreply.github.com>
Co-authored-by: leocavalcante <183722+leocavalcante@users.noreply.github.com>
Co-authored-by: leocavalcante <183722+leocavalcante@users.noreply.github.com>
ed4e6fa to
e723c03
Compare
Co-authored-by: alexgarzao <5495536+alexgarzao@users.noreply.github.com>
This PR implements email validation support for the
validgencode generator, enabling developers to validate email fields in Go structs using theemailtag.Features Added
emailvalidation tag that validates email format using regexrequiredtag for mandatory email fieldsUsage Examples
Implementation Details
IsValidEmail()function intypes/string_utils.gowith comprehensive regex-based validationValidation Examples
The generated validation code efficiently checks email format without reflection, maintaining validgen's performance benefits.
Fixes #5.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.