From 06e9f9497026730c8bfb6ac7ae6337a250024f12 Mon Sep 17 00:00:00 2001 From: Jimmy Pettersson Date: Fri, 22 Aug 2014 15:32:41 +0200 Subject: [PATCH] Added nil check for embedded structs --- binding/binding.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/binding/binding.go b/binding/binding.go index bb6cbde2..92ede2b8 100644 --- a/binding/binding.go +++ b/binding/binding.go @@ -176,6 +176,10 @@ func Validate(obj interface{}) error { if strings.Index(field.Tag.Get("binding"), "required") > -1 { fieldType := field.Type.Kind() if fieldType == reflect.Struct { + if reflect.DeepEqual(zero, fieldValue) { + return errors.New("Required " + field.Name) + } + err := Validate(fieldValue) if err != nil { return err