v9
Question:
Is there any way to change the error message to show the JSON field and not the struct field name?
type TestStruct struct {
Name string `json:"name" validate:"required"`
Lastname string `json:"lastname" validate:"required"`
Address string `json:"address" validate:"required"`
Phone string `json:"phone" validate:"required"`
}
Instead of Key: 'TestStruct.Address' Error:Field validation for 'Address' failed on the 'required' tag
I want to show to user
Error in validation for 'address' failed on the 'required' tag
Yes @droslean, as in the docs RegisterTagNameFunc
here is an example in the tests.
@joeybloggs Thanks a lot. This is what I was looking for.
Most helpful comment
Yes @droslean, as in the docs RegisterTagNameFunc
here is an example in the tests.