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

Allow for manually setting field name in error message #127

Closed dlpetrie closed 4 years ago

dlpetrie commented 4 years ago

I have an issue where I have a field name collision with an interface, so I had to change the field name from "Name" to "Name" or "TheName". I don't see an option to edit this in the error message. I would like to return just "Name: {msg}" as the error message instead of "Name: {msg}". It may also be beneficial to be able to optionally target a struct tag for this value so I can use a json tag as the field name when using json, and another tag when validating something else.

dlpetrie commented 4 years ago

Sorry, this looks like it already exists. Didn't see in the docs