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
For some reason it's impossible to use binding:"required" for query params
type LimitOffset struct { Offset int `form:"offset" binding:"required"` Limit int `form:"limit" binding:"required"` } func CategoryBooks(conn *mgo.Collection, c *gin.Context) { var query_params LimitOffset if err := c.BindQuery(&query_params); err != nil { badRequestResponse(c, err) return } ... }
response: {"description":"Key: 'LimitOffset.Offset' Error:Field validation for 'Offset' failed on the 'required' tag","status":"error"}
{"description":"Key: 'LimitOffset.Offset' Error:Field validation for 'Offset' failed on the 'required' tag","status":"error"}
url with query params:
http://localhost:8000/categories/Python?offset=0&limit=2
The text was updated successfully, but these errors were encountered:
I try it.I'm fine.
Sorry, something went wrong.
@mdnight Can you provide mini codes to help reproduce this issue?
@mdnight I use the follow code it's ok.
package main import ( "fmt" "github.com/gin-gonic/gin" ) type LimitOffset struct { Offset int `form:"offset" binding:"required"` Limit int `form:"limit" binding:"required"` } func main() { r := gin.Default() r.GET("/t", func(c *gin.Context) { var query_params LimitOffset if err := c.BindQuery(&query_params); err != nil { fmt.Println(err) return } fmt.Println("ok") }) r.Run() }
No branches or pull requests
Description
For some reason it's impossible to use binding:"required" for query params
response:
{"description":"Key: 'LimitOffset.Offset' Error:Field validation for 'Offset' failed on the 'required' tag","status":"error"}
url with query params:
The text was updated successfully, but these errors were encountered: