Skip to content

v2.1.0

Compare
Choose a tag to compare
@guiferpa guiferpa released this 30 Nov 21:24
· 8 commits to master since this release
75cfbf6

Loyalty on show field name

  • If there is JSON tag on struct the gody will get the field name from json tag value

  • Example where struct has a JSON tag

type Response struct {
   FirstName string `validate:"not_empty" json:"fname"`
}

resp := Response{}

if validated, err := validator.Validate(resp); err != nil {
    ...
}

// output error: field fname cannot be empty
  • Example where struct hasn't a JSON tag
type Response struct {
   FirstName string `validate:"not_empty"`
}

resp := Response{}

if validated, err := validator.Validate(resp); err != nil {
    ...
}

// output error: field firstName cannot be empty

issue #13