asaskevich / govalidator

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

Custom validation messages with field data #287

Open petherin opened 6 years ago

petherin commented 6 years ago

Standard validation messages include the value of the validated field, but when you use a custom validation message, this data is lost.

Could we have a way of including the data from the validated field. Maybe by including %s or %v. In the example below, cust_uuid_func is a custom validation function:

type Example struct {
   UUIDField   string   `valid:"uuidv4,cust_uuid_func~UUIDField: uuid %s not found,required"`
}
sergeyglazyrindev commented 3 years ago

Hello guys! I forked this package cause owner disappeared. Hope, he will be back, but it would be easier to merge these changes back if he is back Link to my repo: create issue there and we'll discuss it.