-
Notifications
You must be signed in to change notification settings - Fork 598
go: multi-error validation with ValidateAll() #468
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
Conversation
This reverts commit 758c5fc. Signed-off-by: Daniel Hochman <danielhochman@users.noreply.github.com>
Signed-off-by: Daniel Hochman <danielhochman@users.noreply.github.com>
Signed-off-by: Daniel Hochman <danielhochman@users.noreply.github.com>
Signed-off-by: Daniel Hochman <danielhochman@users.noreply.github.com>
Signed-off-by: Daniel Hochman <danielhochman@users.noreply.github.com>
Signed-off-by: Daniel Hochman <danielhochman@users.noreply.github.com>
Signed-off-by: Daniel Hochman <danielhochman@users.noreply.github.com>
Signed-off-by: Daniel Hochman <danielhochman@users.noreply.github.com>
… multierror-validation Signed-off-by: Daniel Hochman <danielhochman@users.noreply.github.com>
| } | ||
| // AllErrors returns a list of validation violation errors. | ||
| func (m {{ multierrname . }}) AllErrors() []error { return m } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For nested scenarios, I wonder if it's worth adding a message that returns all errors recursively as well to completely flatten a tree of errors? If you feel like that complexity might be too much to implement here I'm more than happy to agree that it should be implemented in clients b/c this is already a great step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thing is, such a func is quite complex, and yet basically 100% operates on interfaces (doesn't need to be specialized per-error-type), so IMO it doesn't need to be a method, and potentially it could be put as a "helper" func in an external package, e.g. a subpackage of PGV for being imported separately. Still, I think it could make quite a lot of sense to add such a func (or even method if really insisted), maybe with a "walker/visitor"-like signature, but I'd personally vote for working on one in a separate PR. And @brandoncole if you're really interested in this topic, maybe you'd like to try your hand at writing such a PR yourself? 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that suggestion, it would cut down on the boilerplate and I agree it could probably just be a centrally defined function.
Signed-off-by: Daniel Hochman <danielhochman@users.noreply.github.com>
|
I found this much easier to review relative to 5ef93ae, right before reverting take 1 of this. Even containing all the changes from dd3f943, the diff is tiny! danielhochman/protoc-gen-validate@5ef93ae...multierror-validation |
|
Just wanted to say thank you once again to all the folks involved in this great work 🙏 |
Signed-off-by: Daniel Hochman <danielhochman@users.noreply.github.com>
| } | ||
| // AllErrors returns a list of validation violation errors. | ||
| func (m {{ multierrname . }}) AllErrors() []error { return m } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thing is, such a func is quite complex, and yet basically 100% operates on interfaces (doesn't need to be specialized per-error-type), so IMO it doesn't need to be a method, and potentially it could be put as a "helper" func in an external package, e.g. a subpackage of PGV for being imported separately. Still, I think it could make quite a lot of sense to add such a func (or even method if really insisted), maybe with a "walker/visitor"-like signature, but I'd personally vote for working on one in a separate PR. And @brandoncole if you're really interested in this topic, maybe you'd like to try your hand at writing such a PR yourself? 🙂
Signed-off-by: Daniel Hochman <danielhochman@users.noreply.github.com>
akavel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you so much @danielhochman ! ❤️ 🚀
Signed-off-by: Daniel Hochman <danielhochman@users.noreply.github.com>
cf0a60b to
8e80c7b
Compare
|
@akonradi ready to go! |
|
Thanks, all! |
|
Huge thanks @danielhochman for stepping in, following up with a new version and taking it up to the end! ❤️ |
protoc-gen-validate is release under the v0.6.2: https://github.com/envoyproxy/protoc-gen-validate/releases/tag/v0.6.2 The release contains the merge PR about "multi-error validation with ValidateAll()": bufbuild/protoc-gen-validate#468
Updated version of #455 using two methods
Validate()andValidateAll()instead of moving to a single methodValidate(all bool). This retains compatibility with the existing interface checks in other modules such as:Fixes #47
Co-authored-by: Mateusz Czapliński mateusz.czaplinski@wpengine.com