Skip to content

fix: validate wrapped map values after endkeys - #1638

Open
LeulTew wants to merge 1 commit into
go-playground:masterfrom
LeulTew:leultew-validator-contract-fix
Open

LeulTew wants to merge 1 commit into
go-playground:masterfrom
LeulTew:leultew-validator-contract-fix

Conversation

@LeulTew

@LeulTew LeulTew commented Sep 18, 2026

Copy link
Copy Markdown

Fixes Or Enhances

Validate struct-valued map entries after endkeys even when they are held in interfaces, nested pointers, or custom value types. This builds on #1433 by using the normal field traversal instead of checking only the map value's immediate kind.

Validation limit: Race testing remains unverified: Windows CGO was unavailable, and the existing Linux environment was stopped.

Implementation and validation

The key-only fallback handled concrete structs and single pointers but silently skipped equivalent wrapped values. Passing the remaining tags, including nil, to traverseField reuses its existing unwrapping, nil handling, and nested-struct validation.

  • Add 24 input cases exercised through both Var and Struct, including valid and invalid wrappers, typed nils, nested collections without another dive, and custom extraction. Assert error namespaces, JSON field names, tags, parameters, values, kinds, and types.
  • On unchanged master, 18 of those 48 API cases fail and 30 controls pass. All 48 pass with the fix.
  • Go 1.27.1 on Windows: all 25 module packages pass the non-race coverage suite; vet, normal builds, and the validator_novalidatefn build pass.
  • Go 1.25.14 on Windows: the new regression and related tests pass, as do vet and both builds.
  • Additional public-API checks pass on both Go versions for aliases, translations, callback context, nil handling, explicit value tags, and concurrent reuse.
  • The repository's golangci-lint v2.13.1 configuration reports no issues on both Go versions. Both changed code files are gofmt-clean. The unrelated extra blank line in doc.go's noneof section produces the same formatting difference on base and head and is left unchanged.
  • Allocation counts match across the 66 existing benchmarks and four focused map cases. Timing samples varied; no throughput claim is made.

The original struct-value fallback was contributed by junaid2005p in #1433. This follow-up does not reopen or claim to newly resolve the original concrete-struct report.

Make sure that you've checked the boxes below before you submit PR:

  • Tests exist or have been written that cover this particular change.

@go-playground/validator-maintainers

@LeulTew
LeulTew requested a review from a team as a code owner September 18, 2026 20:43
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.

1 participant