fix: support validation of google/uuid.UUID type#308
Merged
inhere merged 1 commit intogookit:masterfrom Sep 2, 2025
Merged
Conversation
Pull Request Test Coverage Report for Build 17394870035Details
💛 - Coveralls |
There was a problem hiding this comment.
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
convTypeByBaseKindfunction signature by removing the unused middle parameter - Updated all callers to use the streamlined conversion approach
- Enhanced error handling in
convValAsFuncValArgTypeto 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
close #294
This change unifies all type conversions for validation arguments through
convTypeByBaseKind, leveragingreflects.ConvToKindinternally.As a result, custom types—including
github.com/google/uuid.UUID—are now correctly coerced to string when they implementfmt.Stringer.This allows the uuid validator to validate google/uuid.UUID fields without error, resolving issue #294.