-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: panics when private field is validated #1423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
,omitnil
and 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.getValue
must be used instead.In case of casting to
string
,fmt
is 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