diff --git a/tonic/handler.go b/tonic/handler.go index 6664bc6..c104823 100644 --- a/tonic/handler.go +++ b/tonic/handler.go @@ -154,7 +154,7 @@ func RegisterValidation(tagName string, validationFunc validator.Func) error { // // eg. to use the names which have been specified for JSON representations of structs, rather than normal Go field names: // -// validate.RegisterTagNameFunc(func(fld reflect.StructField) string { +// tonic.RegisterTagNameFunc(func(fld reflect.StructField) string { // name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0] // if name == "-" { // return "" @@ -162,6 +162,7 @@ func RegisterValidation(tagName string, validationFunc validator.Func) error { // return name // } func RegisterTagNameFunc(registerTagFunc validator.TagNameFunc) { + initValidator() validatorObj.RegisterTagNameFunc(registerTagFunc) }