Open darklam opened 7 months ago
Thanks fro the PR @darklam
I will have to think hard on if this could cause any breaking side-effects, see here for details.
Thanks fro the PR @darklam
I will have to think hard on if this could cause any breaking side-effects, see here for details.
Yes, agreed that this should be scrutinized a lot regarding breaking changes before merging. I'm happy to add more test cases if there are any specific ones coming to mind.
Also, my first thought was indeed to change some baked ins like gte to handle nil cases, but it didn't seem like the way to go because it became quite repetitive.
I think that the check for that should happen before getting to these validators (as the original intention seems to be with the runValidationWhenNil
flag), but of course this is not an informed opinion as I'm quite new with the codebase 😄
Fixes Or Enhances
Fixes #907 (and possibly others?)
At first I found it weird that the
required_if
affected the behavior of thegte
tag, but after some debugging it seems that the conditionrunValidationWhenNil
is not checked for each field tag, but only for the first one. In this case it was set to true for therequired_if
tag, but set to false forgte
, so when therequired_if
preceded thegte
tag it meant that the field was incorrectly validated throughgte
even when it was nil.Make sure that you've checked the boxes below before you submit PR:
@go-playground/validator-maintainers