Skip to content

feat: omit blank tag names from namespace#1567

Open
abemedia wants to merge 1 commit into
go-playground:masterfrom
abemedia:feat--omit-blank-tag-names-from-namespace
Open

feat: omit blank tag names from namespace#1567
abemedia wants to merge 1 commit into
go-playground:masterfrom
abemedia:feat--omit-blank-tag-names-from-namespace

Conversation

@abemedia
Copy link
Copy Markdown

@abemedia abemedia commented Apr 23, 2026

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.

Copy link
Copy Markdown
Contributor

@deankarn deankarn left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants