Added nil check for embedded structs
This commit is contained in:
		| @ -176,6 +176,10 @@ func Validate(obj interface{}) error { | |||||||
| 			if strings.Index(field.Tag.Get("binding"), "required") > -1 { | 			if strings.Index(field.Tag.Get("binding"), "required") > -1 { | ||||||
| 				fieldType := field.Type.Kind() | 				fieldType := field.Type.Kind() | ||||||
| 				if fieldType == reflect.Struct { | 				if fieldType == reflect.Struct { | ||||||
|  | 					if reflect.DeepEqual(zero, fieldValue) { | ||||||
|  | 						return errors.New("Required " + field.Name) | ||||||
|  | 					} | ||||||
|  |  | ||||||
| 					err := Validate(fieldValue) | 					err := Validate(fieldValue) | ||||||
| 					if err != nil { | 					if err != nil { | ||||||
| 						return err | 						return err | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user