-
Notifications
You must be signed in to change notification settings - Fork 124
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
how to validate struct in struct? #120
Comments
I have the same question. |
I have the same question too. |
same question |
1 similar comment
same question |
There is an example of a nested struct validation but it it might get things wrong if the nested struct has the same keys as the parent: https://github.com/thedevsaddam/govalidator/blob/master/doc/NESTED_STRUCT.md |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
code like this
// QueryPageProjectGrailRequest Request 请求
type QueryPageProjectGrailRequest struct {
PageNo int32
json:"page_no"
// 页码PageSize int32
json:"page_size"
// 每页数量Sort string
json:"sort"
// 排序,支持多个 such as "col1 desc, col2 asc"Filter []queryProjectGrailFilter
json:"filter"
// 筛选(高级查询)Keywords []string
json:"keywords"
// 全文检索能力}
type queryProjectGrailFilter struct {
Field string
json:"field"
Condition string
json:"condition"
Relation string
json:"relation"
Value string
json:"value"
}
I don't know how to validator field in
filter
? such as filter.relation// relation didn't work
rules := govalidator.MapData{
"page_no": []string{"required", "numeric_between:1,100000"},
"page_size": []string{"required", "numeric_between:1,1000"},
"relation": []string{"between:1,5"},
}
The text was updated successfully, but these errors were encountered: