Closed
Description
Package version eg. v9, v10: v10
Issue, Question or Enhancement:
Is there a way to validate optional fields? let's say I want to validate if field str
has either length 0 (not included) or length greater than 5.
Code sample, to showcase or reproduce:
Currently, I made a custom validator and tag like so:
type TestStruct {
TestStr string `validate:"optional_gte=5"`
}
So these strings will pass: ""
"galang"
. These will fail: "ka"
.
Is there any way to do this built-in? if not, I can submit a PR with my custom tags if it's beneficial.
Metadata
Metadata
Assignees
Labels
No labels