my form struct is like this:
type XXX struct {
Offset int `binding:"required"`
}
And my test case is like this:
curl http://127.0.0.1:8080/xxx?offset=0
You need a form:"offset" tag:
type XXX struct {
Offset int `form:"offset" binding:"required"`
}
Is there an error, or is it just passing validation when you would expect it too?
If it's the latter then offset will always exist due to go's a static nature, but could use a pointer to integer and use the "exists" tag instead of "required" more details can be found https://github.com/go-playground/validator/issues/225 even though it's about bool, the same principal applies.
I came across the same problem, got it!
Most helpful comment
You need a
form:"offset"tag: