-
Notifications
You must be signed in to change notification settings - Fork 592
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Customized error messages on validation failures #74
Comments
Hi, is there a way to do this even if this is not yet developed inside protoc-gen-validate. |
How ? Could you show me an example? |
Hi is this feature available now? |
This feature is not available, but we're happy to accept pull requests. The first step is figuring out how we want to represent this in the validation annotations. Any suggestions? |
Yeah, I'm definitely interested in this as well. I've been considering 2 approaches:
and then use it in the templates like
If this isn't overridden in a translation/config.yaml file, it will output the default like
to show something with "characters" instead of "runes" to the end users. Note that you may need to support both of these options. The first allows you to customize an error message for a specific field; e.g., this is very useful for string regexes where you don't want to show your end users a regex, but something they'll understand. The second option lets you change the "standard" messages to make sense for your end users. |
we need this feature, pls review the pr #398 and merge |
Very helpful feature, we need this one. |
Signed-off-by: Mateusz Czapliński <mateusz.czaplinski@wpengine.com>
After modifying the harness.proto in an earlier commit, non-Go harnesses broke and need to be adjusted. Signed-off-by: Mateusz Czapliński <mateusz.czaplinski@wpengine.com>
After modifying the harness.proto in an earlier commit, non-Go harnesses broke and need to be adjusted. Signed-off-by: Mateusz Czapliński <mateusz.czaplinski@wpengine.com>
After modifying the harness.proto in an earlier commit, non-Go harnesses broke and need to be adjusted. Signed-off-by: Mateusz Czapliński <mateusz.czaplinski@wpengine.com>
* go: add bool arg to Validate (#47) In generated messages, modify the Validate func to take bool argument. In a later commit, this will be used to distinguish "fail on first error" mode from "extensively find as many as possible errors". Signed-off-by: Mateusz Czapliński <mateusz.czaplinski@wpengine.com> * go: enable multi-error validation (#47) Modify the templates to allow retrieving multiple errors from a Validate func, not just stopping on the first one. Signed-off-by: Mateusz Czapliński <mateusz.czaplinski@wpengine.com> * tests: prepare harness for multi-errors (#47) In test harness executor, add support for languages which can find multiple validation errors at once. Signed-off-by: Mateusz Czapliński <mateusz.czaplinski@wpengine.com> * go: test multi-error validation (#47) Signed-off-by: Mateusz Czapliński <mateusz.czaplinski@wpengine.com> * go tests: check if multi-error was returned (#47) Ensure that a non-nil response from Validate(true) always fulfills the "multi-error" interface (has AllErrors() method). Signed-off-by: Mateusz Czapliński <mateusz.czaplinski@wpengine.com> * go tests: compare 1st msg of multi-error (#47) Compare the first message returned by Validate(true) to the one returned by Validate(false). Signed-off-by: Mateusz Czapliński <mateusz.czaplinski@wpengine.com> * go tests: repeated TestResult.Reasons field (#74) Signed-off-by: Mateusz Czapliński <mateusz.czaplinski@wpengine.com> * tests: fix TestResult.Reasons in non-Go tests (#74) After modifying the harness.proto in an earlier commit, non-Go harnesses broke and need to be adjusted. Signed-off-by: Mateusz Czapliński <mateusz.czaplinski@wpengine.com>
Hello, Is the work ongoing on this. This could be ver useful. |
Hi ,Is this enhancement can work on some version ? |
Need this feature. Any one can help? |
Having this would be really amazing. Please complete this feature. |
Please complete this feature. This feature very useful. |
it's good feature. |
什么时候能加上这个内容~~期待 |
Anyone knows when this will be done? |
This is super useful, one of the most wanted features. Hope it can be merged soon. |
This one is tricky, there is an ongoing discussion happening between a few of us at buf to make sure this becomes a reality |
Please complete this feature. This feature very useful. |
We need this feature.Please complete this feature. |
@elliotmjackson we also need this, so we may be interested in contributing an implementation (if we can agree reasonably quickly on what needs to be done). I can open a new issue if needed. |
Please complete this feature. This feature very useful. |
现在可以用了吗 |
Please complete this feature. This feature very useful. |
This would be very useful. |
Any news on this feature? Or is it no longer worth hoping ... (( |
The lib is already awesome, the only piece missing is this feature... |
I had opened #546 but @elliotmjackson closed it with "won't fix" 🤔 |
现在有这个功能了吗? |
1 similar comment
现在有这个功能了吗? |
This issue has been around for 5 years. What is the reason why custom error messages are not supported? This has brought us a lot of trouble and may be the reason why we give it up. |
i have given up because it |
Me too. Is there a better alternative? |
i use protoc-go-inject-tag and struct validator instead |
Have you looked at https://github.com/bufbuild/protovalidate? |
let me try, tks |
Good news! this is currently available in the protovalidate project. I'd like to clarify that this feature won't be implemented in protoc-gen-validate, as our focus is now on protovalidate to offer an enhanced and more comprehensive experience within the Protobuf ecosystem. Given that you can achieve your desired functionality through protovalidate, I will be closing this issue. If you have more questions or suggestions, please don't hesitate to share them with us. |
i need it |
Is it possible to specify a custom message for validation failures? For example, if a min_length validation fails, I would like to return a reason that doesn't reference 'runes'. Or be able to understand the error message returned is a minimum length violation, and translate that to my own messaging.
I don't see a way to do either; i don't see a way to specify a custom message in the validation option in the proto file, and the error returned is specific to the message, but not (even more) specific to the min_len validation.
Thanks!
The text was updated successfully, but these errors were encountered: