You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi I know you've already provided me with a lot of help.
I have another question, I know this might not be directly related to Fizz, however I cannot seem to
work out how to get it working with Fizz/Tonic. However others can get it work with Gin directly.
It is around input validation errors, I know validators is used to check the incoming data. So if I do
curl -X POST http://localhost:8080/game -H "Content-Type: application/json" -d "{\"name\":\"quibly\",\"ruls_url\":\"https://gitlab.com/banter-bus/games\"}"# Output
{
"message": "binding error: Key: 'NewGame.RulesURL' Error:Field validation for 'RulesURL' failed on the 'required' tag"
}
I've tried to add a custom validator to gin as Validators maintainer suggests here
binding.Validator=new(defaultValidator)
engine:=gin.New()
engine.Use(cors.Default())
fizzApp:=fizz.NewFromEngine(engine)
// ....infos:=&openapi.Info{
Title: "Banter Bus",
Description: "The API definition for the Banter Bus server.",
Version: "1.0.0",
}
I was wondering if you could suggest a way I could get the JSON tag (`rules_url) from the struct rather than the struct field name(RulesURL). I've tried debugging it myself with breakpoints but I cannot seem to work it out. Any help would be appreciated thanks.
P.S. Sorry for the information overload.
The text was updated successfully, but these errors were encountered:
Hi I know you've already provided me with a lot of help.
I have another question, I know this might not be directly related to Fizz, however I cannot seem to
work out how to get it working with Fizz/Tonic. However others can get it work with Gin directly.
It is around input validation errors, I know validators is used to check the incoming data. So if I do
Where the expected data is modelled like:
I would like to use just get the json field names i.e.
rules_url
and create my own error message to return back to the client.Which outputs:
I've tried to add a custom validator to gin as Validators maintainer suggests here
Where the
defaultValidator
looks like:I was wondering if you could suggest a way I could get the JSON tag (`rules_url) from the struct rather than the struct field name(RulesURL). I've tried debugging it myself with breakpoints but I cannot seem to work it out. Any help would be appreciated thanks.
P.S. Sorry for the information overload.
The text was updated successfully, but these errors were encountered: