-
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
fix ValidateMap and field references #1219
base: master
Are you sure you want to change the base?
fix ValidateMap and field references #1219
Conversation
return v.validateMapCtx(ctx, data, data, rules) | ||
} | ||
|
||
// validateMapCtx will track the original "root" map (in case of nesting) which will allow for Field reference validation |
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.
I was not sure how y'all prefer naming this, so I just lowercased the "inner loop" func here.
I also made this new func
for the implementation, since the signature of the exported one would otherwise change - and it made said signature clunky having to pass in same var as root
and data
ac59f8b
to
48ccdec
Compare
48ccdec
to
0b97b35
Compare
bump on this one 🙏 |
bumping on this @deankarn |
namespace = namespace[endIdx+1:] | ||
// If we exceeded the length of the namespace, then we're at the end | ||
// of the namespace traversal, so set it to empty value to break loop | ||
if endIdx+1 > len(namespace) { |
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.
Is this code formatted ?
I would expect
if endIdx+1 > len(namespace) { | |
if endIdx + 1 > len(namespace) { |
Maybe I'm wrong, but a gofmt might help
ctag := v.fetchCacheTag(tag) | ||
|
||
val := reflect.ValueOf(field) | ||
vd := v.pool.Get().(*validate) |
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.
No type assertion check here?
vd := v.pool.Get().(*validate) | |
vd, ok := v.pool.Get().(*validate) | |
if !ok { | |
return nil | |
} |
Fixes Or Enhances
Implement support for
ValidateMap
usingField
referencesFixes #893
Fixes #876
Fixes #943
Make sure that you've checked the boxes below before you submit PR:
@go-playground/validator-maintainers