pull/1049/head
Lâm Hoàng Phúc 2 years ago
parent c7e0172e0f
commit 2d96ecdadc
  1. 2
      cache.go
  2. 6
      validator_instance.go

@ -289,7 +289,7 @@ func (v *Validate) parseFieldTagsRecursive(tag string, fieldName string, alias s
if wrapper, ok := v.validations[current.tag]; ok { if wrapper, ok := v.validations[current.tag]; ok {
current.fn = wrapper.fn current.fn = wrapper.fn
current.runValidationWhenNil = wrapper.runValidatinOnNil current.runValidationWhenNil = wrapper.runValidationOnNil
} else { } else {
panic(strings.TrimSpace(fmt.Sprintf(undefinedValidation, current.tag, fieldName))) panic(strings.TrimSpace(fmt.Sprintf(undefinedValidation, current.tag, fieldName)))
} }

@ -70,8 +70,8 @@ type CustomTypeFunc func(field reflect.Value) interface{}
type TagNameFunc func(field reflect.StructField) string type TagNameFunc func(field reflect.StructField) string
type internalValidationFuncWrapper struct { type internalValidationFuncWrapper struct {
fn FuncCtx fn FuncCtx
runValidatinOnNil bool runValidationOnNil bool
} }
// Validate contains the validator settings and cache // Validate contains the validator settings and cache
@ -235,7 +235,7 @@ func (v *Validate) registerValidation(tag string, fn FuncCtx, bakedIn bool, nilC
if !bakedIn && (ok || strings.ContainsAny(tag, restrictedTagChars)) { if !bakedIn && (ok || strings.ContainsAny(tag, restrictedTagChars)) {
panic(fmt.Sprintf(restrictedTagErr, tag)) panic(fmt.Sprintf(restrictedTagErr, tag))
} }
v.validations[tag] = internalValidationFuncWrapper{fn: fn, runValidatinOnNil: nilCheckable} v.validations[tag] = internalValidationFuncWrapper{fn: fn, runValidationOnNil: nilCheckable}
return nil return nil
} }

Loading…
Cancel
Save