I'm trying to validate a struct which has two fields, one of them is required and the other one is not.
This is the struct:
type man struct {
// required: true
Numbers []int `json:"numbers"`
// required: false
Pass bool `json:"pass"`
}
In order to validate I'm using this package: https://pkg.go.dev/gopkg.in/validator.v2
My goal is to create the below condition:
Numbers is nonzero OR pass is true.
However, if I define numbers as nonzero it will block the check of the Pass field.
I've tried to create a customized validator function, but since one of the fields is not required, I'm not sure how to build this conditions.
Thanks!