go-ozzo / ozzo-validation

An idiomatic Go (golang) validation package. Supports configurable and extensible validation rules (validators) using normal language constructs instead of error-prone struct tags.
MIT License
3.73k stars 224 forks source link

showing '-' as field name in error for hidden fields #140

Open Siltaz opened 3 years ago

Siltaz commented 3 years ago

I'm validating a User struct whose password field is not exposed to the client. This is my user struct

type User struct {
    Name      string              `json:"name" bson:"name"`
    Email     string              `json:"email" bson:"email"`
    Password  string              `json:"-" bson:"password"`
}

and when validation fails for Password field it returns error as:

{
  "-": "the length must be between 8 and 18"
}

Is there any way so that i can pass field name to it ?