💯Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
validator/baked_in.go

18 lines
404 B

package validator
import (
"log"
"reflect"
)
var bakedInValidators = map[string]ValidationFunc{
"required": isRequired,
}
func isRequired(field interface{}, param string) bool {
log.Printf("Required:%s Valid:%t\n", field, field != nil && field != reflect.Zero(reflect.TypeOf(field)).Interface())
return field != nil && field != reflect.Zero(reflect.TypeOf(field)).Interface()
// return true
}