Skip to content
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

Error in validating map[string]interface{} struct field #454

Open
dex80526 opened this issue Oct 11, 2021 · 0 comments
Open

Error in validating map[string]interface{} struct field #454

dex80526 opened this issue Oct 11, 2021 · 0 comments

Comments

@dex80526
Copy link

dex80526 commented Oct 11, 2021

Bug Report

The following struct:

type S struct {
Props map[string]interface{} `valid:"required"`
}
d := S{props: map[string]interface{}{"field": "test"}
result, err := valid.ValidateStruct(d)
...

With the above code, it gets an error: "function only accepts structs; got string;"

However, if the field of Props is private (i.e., props), the validation is skipped.

Q A
Version(s) v0.0.0-20200428143746-21a406dcc535

Summary

The validator does not handle required field of map[string]interface{} correctly.

Current behavior

The current result: false with the error msg of "function only accepts structs; got string;"

How to reproduce

See the above sample code.

Expected behavior

The expected validation result: true (no error)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant