Skip to content
New issue

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

binding对 json 传递为null的struct字段做了struct内各字段的tag检查 #54

Open
lixiangchen-zh opened this issue Aug 19, 2022 · 0 comments

Comments

@lixiangchen-zh
Copy link

type Address struct{
        City  string       `form:"city,required" json:"city,required" query:"city,required"`
} 

type User struct{
        Name      string      `form:"name" json:"name,required" query:"name"`
        Address  *Address   `form:"address" json:"address,omitempty" query:"address"`
}

// request body 为json {"name":"Jack", "address":null}
var user model.User
err = binding.BindAndValidate(c, &user)

预期user能正常的绑定,user.Address == nil,实际上返回错误提示 binding: expr_path=address.city, cause=missing required parameter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant