Skip to content

FieldError Field function returns struct name instead of JSON tag #337

@kerak19

Description

@kerak19

I do have this struct:

data := struct {
    Email    string `validate:"required,email" "json:"email"`
    Password string `validate:"required,min=8" "json:"password"`
}{}

Then i'm using validate.Struct(data) and i'm ranging over ValidationErrors.
Every Field() on error in ValidationErrors returns struct field instead of JSON tag.
For example, data.Email has json tag "email", but it retuns "Email" instead.
Why is that? Documentation clearly says it should return JSON tag.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions