fix: panics when private field is validated#1423
fix: panics when private field is validated#1423nodivbyzero merged 5 commits intogo-playground:masterfrom ykalchevskiy:master
Conversation
|
@deankarn , @nodivbyzero , can you please take a look? |
|
Hello, What issue does your PR address? |
|
Hi @nodivbyzero , Here you go https://go.dev/play/p/D5c3QKQlnWt There are other cases, basically, |
I'll just keep it for myself. util.go#299
`// return regex.MatchString(fmt.Sprintf("%s", fl.Field())) // should be enoungh, add tests to check separately`
nodivbyzero
left a comment
There was a problem hiding this comment.
Thank you for your contribution. I've reviewed and validated your changes - everything looks good to me.
|
@nodivbyzero , thanks, shall we merge? |
Fixes Or Enhances
dive,omitniland time-related validations panic by themselves.panic inside panic happens for most of the checks in case of bad type.
(reflect.Value).Interface()can't be used if a field is private.getValuemust be used instead.In case of casting to
string,fmtis smart enough by itself.In case of getting type with
%T,(reflect.Value).Type()can be safely used.Without these changes tests fail with this error:
Make sure that you've checked the boxes below before you submit PR:
@go-playground/validator-maintainers