asaskevich / govalidator

[Go] Package of validators and sanitizers for strings, numerics, slices and structs
MIT License
6k stars 556 forks source link

Refactored typeCheck to accept parent, fixing array/slice failing required check with empty values #436

Open LCartwright opened 3 years ago

LCartwright commented 3 years ago
Q A
Documentation no
Bugfix yes
BC Break no
New Feature yes
RFC no
QA no

Description

Related too https://github.com/asaskevich/govalidator/issues/334, the root cause seems to be that each element of an array is checked with isEmptyValue and fails the required check if it is empty. Meaning that an array of bytes containing a zero value of the byte type (0x00) will trigger the failure. Solution is to check the array against the zero type first, then ignore any empty values upon digging into each individual element of byte array. I've added a test to reproduce.

Note: IsExistingEmail tests fail for me on a fresh pull from master.

This is just a quick hack together, I welcome some advice on the direction here.

sergeyglazyrindev commented 2 years ago

Hello guys! I forked this package cause owner disappeared. Hope, he will be back, but it would be easier to merge these changes back if he is back Link to my repo: create issue there and we'll discuss it.