Skip to content

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Jan 1, 2026

πŸ“‘ Description

Closes goravel/goravel#303

βœ… Checks

  • Added test cases for my code

@hwbrzzl hwbrzzl requested a review from a team as a code owner January 1, 2026 03:54
@gemini-code-assist
Copy link

Summary of Changes

Hello @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 context.Context into the core validation interfaces and their implementations. This change allows custom validation rules and filters to leverage Go's context mechanism for managing request lifecycles, timeouts, and passing essential request-scoped values, thereby improving the flexibility and robustness of the validation process.

Highlights

  • Context Propagation: The context.Context is now passed to validation rules and filters, enabling context-aware logic for operations like cancellation or request-scoped data access.
  • Interface Updates: The Validation, Rule, and Filter interfaces in contracts/validation/validation.go have been updated to include context.Context in their method signatures (Make, Passes, Message, Handle).
  • Mock Implementations: Corresponding mock implementations in mocks/validation/Filter.go, mocks/validation/Rule.go, and mocks/validation/Validation.go have been adjusted to accommodate the new context.Context parameter.
  • PrepareForValidation Refinement: The PrepareForValidation option now directly accepts a function that receives context.Context and validation.Data, removing the previous dependency on http.Context.
  • Test Coverage: A new test file validation/options_test.go has been added to thoroughly test the validation options, and existing test files (validation/errors_test.go, validation/validation_test.go, validation/validator_test.go) have been updated to pass context.Background() to the Make method and adapt to the new context-aware signatures.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

Copy link

@gemini-code-assist gemini-code-assist bot left a 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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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
Copy link

codecov bot commented Jan 1, 2026

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 70.05%. Comparing base (e7fa6ed) to head (3ab2632).
⚠️ Report is 2 commits behind head on master.

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.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hwbrzzl hwbrzzl merged commit bb9ae1f into master Jan 3, 2026
13 checks passed
@hwbrzzl hwbrzzl deleted the bowen/#303 branch January 3, 2026 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ [Feature] Validations rules should receive context

2 participants