Skip to content

feat: omit blank tag names from namespace - #1567

Merged
nodivbyzero merged 1 commit into
go-playground:masterfrom
abemedia:feat--omit-blank-tag-names-from-namespace
May 26, 2026
Merged

feat: omit blank tag names from namespace#1567
nodivbyzero merged 1 commit into
go-playground:masterfrom
abemedia:feat--omit-blank-tag-names-from-namespace

Conversation

@abemedia

@abemedia abemedia commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Fixes Or Enhances

When RegisterTagNameFunc returns "" (typically for json:"-" or equivalent), the field currently falls back to the struct field name in error namespaces, defeating the tag-name remapping.

This PR adds the WithTagNameFuncBlankOmit option that preserves the blank and omits the field from the error namespace - nested struct levels collapse, and leaf field namespaces trim the trailing separator.

Gated behind an option for v10 backward compatibility. According to @deankarn this was always meant to be the behaviour (see #1426 (comment)) so I've gone off the assumption this will be the default in v11 and followed the example of WithRequiredStructEnabled.

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

@deankarn

Copy link
Copy Markdown
Contributor

Thanks, will try and review tonight after work.

@deankarn deankarn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@abemedia

Copy link
Copy Markdown
Contributor Author

Hey @deankarn @zemzale, thanks for approving. Any chance of getting this merged?

@nodivbyzero
nodivbyzero merged commit feacb34 into go-playground:master May 26, 2026
7 checks passed
@abemedia
abemedia deleted the feat--omit-blank-tag-names-from-namespace branch May 28, 2026 19:16
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.

4 participants