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{
"required": isRequired,
"required": required,
"length": length,
"min": min,
"max": max,
"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()
}

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

Loading…
Cancel
Save