Skip to content

fix: resolve panic when using aliases with OR operator - #1507

Merged
deankarn merged 1 commit into
go-playground:masterfrom
shindonghwi:fix/alias-with-or-operator-766
Dec 21, 2025
Merged

deankarn merged 1 commit into
go-playground:masterfrom
shindonghwi:fix/alias-with-or-operator-766

Conversation

@shindonghwi

@shindonghwi shindonghwi commented Dec 18, 2025 •

Copy link
Copy Markdown
Contributor

Fixes #766

Using aliases with OR operator causes panic:

validate.RegisterAlias("bid2", "numeric")
// validate:"numeric|bid2" → panic: Undefined validation function 'bid2'

The issue is that alias lookup only happens for comma-separated tags, not OR-separated ones. Fixed by adding alias check in the OR parsing logic.

Added tests for various cases (built-in aliases, custom aliases, different positions, etc).

@shindonghwi
shindonghwi requested a review from a team as a code owner December 18, 2025 00:11
@shindonghwi
shindonghwi force-pushed the fix/alias-with-or-operator-766 branch from b792454 to df02f70 Compare December 18, 2025 00:12
@coveralls

coveralls commented Dec 18, 2025 •

Copy link
Copy Markdown

Coverage Status

coverage: 73.773% (+0.02%) from 73.749%
when pulling c3989b5 on shindonghwi:fix/alias-with-or-operator-766
into b0e4ba2 on go-playground:master.

@shindonghwi
shindonghwi force-pushed the fix/alias-with-or-operator-766 branch from df02f70 to b5ae5d3 Compare December 18, 2025 00:15
zemzale
zemzale previously approved these changes Dec 18, 2025

@zemzale zemzale left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Generally looks like a good fix, just some style issues from me.

Comment thread cache.go Resolved
Comment thread validator_test.go Resolved
Alias lookup was missing in OR parsing logic, causing panic when using
aliases like `numeric|myalias`. Fixed by adding alias check before the
undefined validation panic.

Fixes go-playground#766

@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.

Nice work TY

@deankarn
deankarn merged commit 7aba81c into go-playground:master Dec 21, 2025
8 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.

Aliases or'ed with other functions causes a panic Undefined validation function

4 participants