Skip to content

Commit

Permalink
Merge pull request #75 from hmajid2301/fix/register-tag-func
Browse files Browse the repository at this point in the history
 fix: init validator in RegisterTagNameFunc
  • Loading branch information
wI2L authored Jul 4, 2023
2 parents c4f8b2f + 75edfae commit 30eb770
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tonic/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,15 @@ 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 ""
// }
// return name
// }
// })
func RegisterTagNameFunc(registerTagFunc validator.TagNameFunc) {
initValidator()
validatorObj.RegisterTagNameFunc(registerTagFunc)
}

Expand Down

0 comments on commit 30eb770

Please sign in to comment.