Hi, I am new to golang. here I am trying to add payload validation in gin API with the validator package but I am getting an error.
here is my JSON payload and validation enum, please help me with that
{
"phone": "2323232323",
"countryCode": "+12",
"HasAgreedToTermsAndConditions": false
}
type RequestPhoneOtpPayload struct {
Phone string `json:"phone" validate:"required,min=9,max=10"`
CountryCode string `json:"countryCode" validate:"required,min=3,max=3"`
HasAgreedToTermsAndConditions bool `json:"hasAgreedToTermsAndConditions" validate:"required"`
}
error response
{"message":"Key: 'RequestPhoneOtpPayload.Phone' Error:Field validation for 'Phone' failed on the 'required' tag\nKey: 'RequestPhoneOtpPayload.CountryCode' Error:Field validation for 'CountryCode' failed on the 'required' tag\nKey: 'RequestPhoneOtpPayload.HasAgreedToTermsAndConditions' Error:Field validation for 'HasAgreedToTermsAndConditions' failed on the 'required' tag","success":false}