Skip to content

Problems with combining built-in tags #1283

Closed Answered by onnttf
onnttf asked this question in Q&A
Discussion options

You must be logged in to vote

I'm happy to say that I've found a solution using the following code, which uses required_without and excluded_with at the same time.

i := struct {
    User     string `json:"user" validate:"required_without=Role,excluded_with=Role"`
    Role     string `json:"role" validate:"required_without=User,excluded_with=User"`
    Resource string `json:"resource"  validate:"required,uri"`
    Action   string `json:"action"  validate:"required"`
}{}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by onnttf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant