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
Is there a way to list all the required fields using gin-gonic #2811
Comments
@NishantG01
Hope it helps you |
As can be seen in the example, it very well sends the error, but it exposes the code internal struct. Instead I wanted the error to use the tags associated with struct along with listing all the required fields using gin. |
I found a centralized method that may be able to meet your needs
link: https://blog.depa.do/post/gin-validation-errors-handling or link: https://pkg.go.dev/github.com/go-playground/validator#RegisterTranslationsFunc |
Thanks for the example. Appreciate your help.
Basically I am looking for the output in the format
Really Appreciate your help. |
this is my code :
You can see that in the source code, json decode is performed first, and then validated, I think you can achieve the function you want by modifying the source code https://blog.depa.do/post/gin-validation-errors-handling This article explains the use case of |
@jimbirthday
|
@NishantG01 |
@jimbirthday ,
Test Input
Expected output
Can you please help me with it. Do you have any suggestion and pointer to the same. Appreciate your help. |
@NishantG01 |
@jimbirthday ,
|
I understand it should be written like this, you try
|
Description
Generally, we create a struct and add tags for binding. If the binding key is not present gin-gonic will error out with generic message exposing the struct.
Is there a way that we can enlist all the required fields with there tags, and send specific error message pertaining to the field which is not present.
How to reproduce
Expectations
Actual result
Environment
The text was updated successfully, but these errors were encountered: