AgreementNo int`json:"agreement_no" validate:"required"`
I want get zero value from agreement_no request. still required but get zero value so json request null not allow. but validate in echo not allowed zero value.
How can I get this value without remove required validation or there are any solution?
AgreementNo int`json:"agreement_no" validate:"required"`
Validator cannot find the difference between default zero-value and 0 parsed from json, so it interpret all zero-values as empty. The same happens for boolean, strings, etc.
The workaround is to use pointer instead of plain type.
AgreementNo *int`json:"agreement_no" validate:"required"`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With