Golang validator multifield dependency
问题 I'd like to validate the following structure : type CarModel struct { gorm.Model OwnerID int `json:"ownerid" validate:"nonzero"` Type string `json:"type" validate:"regexp=(?)(A|B)"` A string `json:"url" validate:"isurl"` B string `json:"ip" validate:"isip"` } I would like to validate A and B depending on Type, if type = A then A must exist and must be a URL BUT B must not exist if type = B then A must not exist and B must be an IP is this possible with validator ? I did try custom validation