Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correct pointer in errors.As(). Fix "panic: errors: *target must be interface or implement error" in examples. #1378

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

antonsoroko
Copy link
Contributor

@antonsoroko antonsoroko commented Feb 17, 2025

Only *InvalidValidationError implements error, so we must use double pointer.
good explanation: https://www.reddit.com/r/golang/comments/txi397/comment/i3lybab/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
and https://stackoverflow.com/a/69448087/9066110

Fixes Or Enhances

Fixes panic: errors: *target must be interface or implement error for _examples/simple/ and _examples/struct-level/ that was introduced in #1346

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

Only *InvalidValidationError implements error, so must use double
pointer.
@antonsoroko antonsoroko requested a review from a team as a code owner February 17, 2025 19:44
@coveralls
Copy link

Coverage Status

coverage: 74.348%. remained the same
when pulling ef51196 on antonsoroko:fix-examples-errors-as
into 0240917 on go-playground:master.

@deankarn deankarn merged commit 3c162b6 into go-playground:master Feb 18, 2025
15 checks passed
@antonsoroko antonsoroko deleted the fix-examples-errors-as branch February 18, 2025 10:10
KimNorgaard pushed a commit to KimNorgaard/validator that referenced this pull request Feb 25, 2025
…be interface or implement error" in examples. (go-playground#1378)

Only *InvalidValidationError implements error, so we must use double
pointer.
good explanation:
https://www.reddit.com/r/golang/comments/txi397/comment/i3lybab/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
and https://stackoverflow.com/a/69448087/9066110

## Fixes Or Enhances
Fixes `panic: errors: *target must be interface or implement error` for
`_examples/simple/` and `_examples/struct-level/` that was introduced in
go-playground#1346

**Make sure that you've checked the boxes below before you submit PR:**
- [x] Tests exist or have been written that cover this particular
change.

@go-playground/validator-maintainers
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