function rename

pull/16/head
Dean Karn 10 years ago
parent 05d2507495
commit cff7604ce7
  1. 4
      baked_in.go
  2. 2
      validator.go

@ -8,14 +8,14 @@ import (
) )
var bakedInValidators = map[string]ValidationFunc{ var bakedInValidators = map[string]ValidationFunc{
"required": isRequired, "required": required,
"length": length, "length": length,
"min": min, "min": min,
"max": max, "max": max,
"regex": regex, "regex": regex,
} }
func isRequired(field interface{}, param string) bool { func required(field interface{}, param string) bool {
return field != nil && field != reflect.Zero(reflect.TypeOf(field)).Interface() return field != nil && field != reflect.Zero(reflect.TypeOf(field)).Interface()
} }

@ -210,7 +210,7 @@ func (v *Validator) validateFieldByNameAndTag(f interface{}, name string, tag st
return nil return nil
} }
if strings.Contains(tag, omitempty) && !isRequired(f, "") { if strings.Contains(tag, omitempty) && !required(f, "") {
return nil return nil
} }

Loading…
Cancel
Save