I have this struct
// CreateAccount Create Account Data Args
type CreateAccount struct {
....
RegistrationID string `example:"2c45e4ec-26e0-4043-86e4-c15b9cf985a2" json:"registration_id" binding:"max=63"`
ParentID *string `example:"7c45e4ec-26e0-4043-86e4-c15b9cf985a7" json:"parent_id" format:"uuid"`
}
ParentID is a pointer, and it is optional. But if it is provided, it should be uuid.
var params helper.CreateAccount
if err := ctx.ShouldBindJSON(¶ms); err != nil {
...
}
if add this to ParentID binding:"uuid"
, it makes ParentID a required filed! Which is not the case here. If and only if ParentID is given, it should be uuid. Is there anyway to set it up this way.