go-playground / validator

:100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving
MIT License
16.65k stars 1.32k forks source link

dive behaviour #1157

Closed plarsson closed 1 year ago

plarsson commented 1 year ago

Package version eg. v9, v10:

v10.15.3

Issue, Question or Enhancement:

In v10.15.3, we ran into some panic messages saying: dive error! can't dive on a non-slice or map. I checked and discovered that we mistakenly tagged some structs with dive. Dive is only needed and supported on slices and maps, correct?

However version v10.15.1 didn't panic with dive configured on a struct type.

I think the behaviour of dive was "corrected" somehow by: https://github.com/go-playground/validator/commit/9b7c4de75b64b21fe881f0376974c2e32188ed3d?

deankarn commented 1 year ago

@plarsson yes the behaviour was corrected in #1157 and #1122 before that.

I have made special concessions for the required tag as I can understand and appreciate the confusion, especially coming from other languages where a variable can be uninitialized, however the dive tag is clearly documented to only work with arrays, slices and maps.

plarsson commented 1 year ago

ok thanks for the confirmation! We will adjust on our side.