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
With issues:
go version: go version go1.11.4 darwin/amd64
gin version (or commit ref): 1.4.0
operating system: osx
type Data sturct { Name string `json:"name,omitempty" bson:"name,omitempty" binding:"required"` Number string `json:"number,omitempty" bson:"number,omitempty" binding:"required"` } //route var json models.Data err := c.ShouldBindJSON(&json) // it's ok for check condition required
How to use same struct without check condition binding? I use BindJson() have error required when empty field requried.
The text was updated successfully, but these errors were encountered:
// json bind func BindWihtoutBindingTag(c *gin.Context, dest interface{}) error { if c.ContentType() != "application/json" { return errors.New("'BindWithoutBindingTag' only serves for application/json not for " + c.ContentType()) } buf, e := ioutil.ReadAll(c.Request.Body) if e != nil { return e } c.Request.Body = ioutil.NopCloser(bytes.NewReader(buf)) return json.Unmarshal(buf, dest) }
Sorry, something went wrong.
No branches or pull requests
With issues:
go version: go version go1.11.4 darwin/amd64
gin version (or commit ref): 1.4.0
operating system: osx
Description
How to use same struct without check condition binding?
I use BindJson() have error required when empty field requried.
The text was updated successfully, but these errors were encountered: