Replies: 2 comments 1 reply
-
Gin framework automatically assigns zero values to the fields corresponding to query string parameters that are missing. If I understand this correctly, this is why I cannot have an optional URL parameter and use validation rules such as "gt=1800" in the example above (because the value would be If you could add support for a library such as gopkg.in/guregu/null.v4, it would solve the problem. I could define fields as nullable:
and, at the same time, apply validation that wouldn't be affected by zero values. Please consider this feature request. |
Beta Was this translation helpful? Give feedback.
-
Hey @smatric there are actually two ways to do what you want today :)
let me know if this helps. |
Beta Was this translation helpful? Give feedback.
-
My endpoint accepts two optional parameters:
However, validation fails on the field tagged as
alphanum
:How can I make the rule to be applied only when the field has a value?
Beta Was this translation helpful? Give feedback.
All reactions