-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Validating unexported fields #417
Comments
@Jwata A package can only view the unexported fields of types within its own package and so they must be ignored or there will be an exception; this is true of all packages using reflect even the son package. |
OK, so they must be exported to do validate using reflection. |
As far as i know reflect can read an unexported field, but write can't. Check the following link: https://yourbasic.org/golang/access-private-field-reflection/. Also you can use reflect2 package as json-iterator/extra do: https://godoc.org/github.com/json-iterator/go/extra#SupportPrivateFields. Is there's a way that you considirer validate unexported fields? Many thanks un advance. |
@fuintis thanks for the link, I could have sworn this was not possible but I’ll take another look! love to support unexported fields if I can |
Should this issue be reopened ? |
Same here. This issue completely breaks DDD entity pattern. |
Also have the same feeling. Would love this to be looked into. |
+1 |
Yeah, |
Just chiming in. I ran into this issue today. I am new to Go, but happy to help develop, test, or review a proposed solution! |
I reopened this thread because other people also want this feature.
It seems @fuintis gave some ideas, which you may want to check. |
## Add supporting for validation private fields #417 @go-playground/validator-maintainers --------- Co-authored-by: nikolay <[email protected]>
…ound#1234) go-playground#417 @go-playground/validator-maintainers --------- Co-authored-by: nikolay <[email protected]>
Package version eg. v8, v9:
v8 and v9
Question:
I was wondering if it's possible to validate unexported fields. But unexported fields are skipped here.
https://github.com/go-playground/validator/blob/v9/cache.go#L131
Is there any reason for it?
The text was updated successfully, but these errors were encountered: