Merge pull request #137 from joeybloggs/v6-development

Update simple.go file && README
pull/141/head
Dean Karn 9 years ago
commit 32910f84c4
  1. 15
      README.md
  2. 15
      examples/simple.go

@ -170,6 +170,21 @@ func (v valuer) Value() (sql.Value, error) {
return v.Name, nil
}
// ValidateValuerType implements validator.CustomTypeFunc
func ValidateValuerType(field reflect.Value) interface{} {
if valuer, ok := field.Interface().(sql.Valuer); ok {
val, err := valuer.Value()
if err != nil {
// handle the error how you want
return nil
}
return val
}
return nil
}
func main() {
customTypes := map[reflect.Type]validator.CustomTypeFunc{}

@ -118,6 +118,21 @@ func (v valuer) Value() (sql.Value, error) {
return v.Name, nil
}
// ValidateValuerType implements validator.CustomTypeFunc
func ValidateValuerType(field reflect.Value) interface{} {
if valuer, ok := field.Interface().(sql.Valuer); ok {
val, err := valuer.Value()
if err != nil {
// handle the error how you want
return nil
}
return val
}
return nil
}
func main2() {
customTypes := map[reflect.Type]validator.CustomTypeFunc{}

Loading…
Cancel
Save