You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When my needs grew beyond a slice of string, I refactored to a slice of struct. The namespace returned no longer has an index nor the top-level field name:
I immediately suspect that it because the struct used in your array is unexposed(lowercase name) which will limit the I formation the validator package can get from the struct, but I will look into this and verify exactly what's happening.
If you wanted to try with an exposed struct in the mean time that would sure speed things along :)
Package version eg. v8, v9:
gopkg.in/go-playground/validator.v9
Issue, Question or Enhancement:
When the top-level struct is anonymous, diving into a slice of structs returns FieldError with an incorrect namespace.
I started with an anonymous struct and a
json
TagNameFunc. Things went well:When my needs grew beyond a slice of string, I refactored to a slice of struct. The namespace returned no longer has an index nor the top-level field name:
I found that using a named top-level type can work around this, but now I also have to trim a level from the returned namespace:
The text was updated successfully, but these errors were encountered: