-
Notifications
You must be signed in to change notification settings - Fork 106
feat: [#303] Validations rules should receive context #1334
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
Summary of ChangesHello @hwbrzzl, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the validation system by integrating Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with π and π on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request refactors the validation logic to propagate context.Context through various methods, which is a great improvement for cancellability and passing request-scoped data. The changes are consistent across interfaces, implementations, and tests.
I've found a critical bug that was introduced by removing a variable shadow in a loop, which would cause all custom validation rules to behave like the last one. I've also made a suggestion to improve code clarity by renaming a parameter that shadows a package name.
Additionally, I noticed that the import alias for github.com/goravel/framework/contracts/validation is now contractsvalidation in validation/options.go, which is a good, descriptive name. It would be great to apply this alias consistently across all files in the validation package (e.g., validation.go, validation_test.go) for better maintainability.
| } | ||
|
|
||
| func AppendOptions(validator *validate.Validation, options map[string]any) { | ||
| func AppendOptions(ctx context.Context, validation *validate.Validation, options map[string]any) { |
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.
The parameter validation shadows the package name, which can be confusing and is discouraged by Go's style guidelines. Consider renaming it to something like v or validator to improve clarity and avoid shadowing.
| func AppendOptions(ctx context.Context, validation *validate.Validation, options map[string]any) { | |
| func AppendOptions(ctx context.Context, v *validate.Validation, options map[string]any) { |
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1334 +/- ##
=======================================
Coverage 70.05% 70.05%
=======================================
Files 281 281
Lines 16767 16761 -6
=======================================
- Hits 11746 11742 -4
+ Misses 4530 4529 -1
+ Partials 491 490 -1 β View full report in Codecov by Sentry. π New features to boost your workflow:
|
π Description
Closes goravel/goravel#303
β Checks