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

Add support for errors.As #1273

Open
2 tasks done
roman-vanesyan opened this issue Jun 2, 2024 · 0 comments
Open
2 tasks done

Add support for errors.As #1273

roman-vanesyan opened this issue Jun 2, 2024 · 0 comments

Comments

@roman-vanesyan
Copy link

roman-vanesyan commented Jun 2, 2024

  • I have looked at the documentation here first?
  • I have looked at the examples provided that may showcase my question here?

Package version eg. v9, v10:

v10

Issue, Question or Enhancement:

Provide support for the errors.As. Go 1.13+ has addition of errors.As that helps to cast given error the target if it or one of its nested errors implements the type of target.

To add support for the errors.As functionality all publicly available errors should implement As method of the following signature:

As(interface{}) bool

Code sample, to showcase or reproduce:

err := validator.Struct(&v)
if err != nil {
  err = fmt.Errorf("wrapped error: %w", err)
}

// ...

var validationErr *validation.ValidationErrors
ok := errors.As(err, &validationErr) // true
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

No branches or pull requests

1 participant