We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
ShouldBindJSON
EOF
ShouldBindJSON return EOF when the request body is an empty string. This error message is not friendly.
package main import ( "fmt" "github.com/gin-gonic/gin" ) type R struct { C string `form:"c" binding:"required"` } func main() { g := gin.Default() g.POST("/hello", func(c *gin.Context) { if err := c.BindJSON(&R{}); err != nil { fmt.Println(err, len(c.Errors)) } }) g.Run(":9000") }
$ curl --request POST '127.0.0.1:9000/hello' --data ''
print EOF 1. Expect: `Key: 'R.C' Error:Field validation for 'C' failed on the 'required' tag 0` or `invalid request` or `empty body`
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Description
ShouldBindJSON
returnEOF
when the request body is an empty string.This error message is not friendly.
How to reproduce
Expectations
Actual result
Environment
The text was updated successfully, but these errors were encountered: