asaskevich / govalidator

[Go] Package of validators and sanitizers for strings, numerics, slices and structs
MIT License
5.97k stars 554 forks source link

Field name included in custom error messages #487

Open jorgefuertes opened 1 year ago

jorgefuertes commented 1 year ago
Q A
Documentation no
Bugfix yes
BC Break no
New Feature no
RFC no
QA no

Description

The error strings are different from the provided error messages to the custom error messages. First ones included the field name. When using this feature from a front application, for example, with the custom error message you don't know which field is referred.

Go validator error message: password: does not validate as stringlength(3|50)

Custom error messages: Should have between 3 to 50 chars.

While it should be: password: Should have between 3 to 50 chars.

I've modified the test to be OK with the new custom messages.