Open donknap opened 11 months ago
ChunkNumber should not be validated when Finish is equal to 1 ?
Because the default value of the int type of the struct is 0,how can I fix it ?
The required_if
tag does not stop validation when the requirement is met. For this reason, so long as validation of previous tags succeed, gt=0
will always get evaluated.
It's not clear to me whether ChunkNumber
can either be positive or negative when Finish
is empty, or if ChunkNumber
must be empty when Finish
is equal to 1.
Some clarification on your requirements would be helpful as to provide you with a proper solution.
As a side note:
omitempty,eq=1|eq=0
is effectively the same as omitempty,eq=1
or eq=1|eq=0
number
tag is meant for validating numbers represented as strings.
Package version eg. v9, v10:
v10.14.1
Issue, Question or Enhancement:
When using required_if, when the required_if condition does not take effect, it also verifies gt=0
Code sample, to showcase or reproduce:
when post finish = 0 and chunkNumber = -1:
error message: Key: 'ParamsValidate.ChunkNumber' Error:Field validation for 'ChunkNumber' failed on the 'gt' tag
when post finfish = 1 and chunkNumber = -1 or without chunkNumber :
error message: Key: 'ParamsValidate.ChunkNumber' Error:Field validation for 'ChunkNumber' failed on the 'gt' tag
===================
Question:
ChunkNumber should not be validated when Finish is equal to 1 ?
Because the default value of the int type of the struct is 0,how can I fix it ?