Custom error message template
Customizing the default Valgo error messages is possible through the New() function as it’s explained in the Localizing a validation session with New section, however the Valgo validators allow to customize the template of a specific template validator rule. Below is an example illustrating this with the String empty validator rule.
val := v.Is(v.String("", "address_field", "Address").Not().Empty("{{title}} must not be empty. Please provide the value in the input {{name}}."))
out, _ := json.MarshalIndent(val.Error(), "", " ")fmt.Println(string(out))output:
{ "address": [ "Address must not be empty. Please provide the value in the input address_field." ]}