Skip to content

fix: support validation of google/uuid.UUID type#308

Merged
inhere merged 1 commit intogookit:masterfrom
almas-x:master
Sep 2, 2025
Merged

fix: support validation of google/uuid.UUID type#308
inhere merged 1 commit intogookit:masterfrom
almas-x:master

Conversation

@almas-x
Copy link
Contributor

@almas-x almas-x commented Sep 2, 2025

close #294

This change unifies all type conversions for validation arguments through convTypeByBaseKind, leveraging reflects.ConvToKind internally.
As a result, custom types—including github.com/google/uuid.UUID—are now correctly coerced to string when they implement fmt.Stringer.
This allows the uuid validator to validate google/uuid.UUID fields without error, resolving issue #294.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 17394870035

Details

  • 5 of 6 (83.33%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 96.996%

Changes Missing Coverage Covered Lines Changed/Added Lines %
validating.go 3 4 75.0%
Totals Coverage Status
Change from base Build 17230117630: 0.2%
Covered Lines: 2938
Relevant Lines: 3029

💛 - Coveralls

@inhere inhere requested a review from Copilot September 2, 2025 09:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes validation of google/uuid.UUID types by unifying type conversion logic throughout the validation system. The change removes the intermediate basicKindV2 step and directly uses convTypeByBaseKind with reflects.ConvToKind, enabling proper string coercion for custom types that implement fmt.Stringer.

  • Simplified the convTypeByBaseKind function signature by removing the unused middle parameter
  • Updated all callers to use the streamlined conversion approach
  • Enhanced error handling in convValAsFuncValArgType to return false on conversion failures

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
util.go Removed unused parameter from convTypeByBaseKind function signature
validating.go Updated type conversion calls to use simplified signature and improved error handling
validators.go Updated RequiredIf validator to use new function signature
validate_test.go Added comprehensive tests for the updated conversion function including Stringer interface support

@inhere inhere merged commit 306d343 into gookit:master Sep 2, 2025
17 of 18 checks passed
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.

uuid validator not support github.com/google/uuid.UUID

4 participants