Browse Source

Validate should ignore unexported struct fields.

Andrey Smirnov 11 năm trước cách đây
mục cha
commit
e36f2945bb
1 tập tin đã thay đổi với 2 bổ sung2 xóa
  1. 2 2
      binding/binding.go

+ 2 - 2
binding/binding.go

@@ -169,8 +169,8 @@ func Validate(obj interface{}) error {
 		for i := 0; i < typ.NumField(); i++ {
 			field := typ.Field(i)
 
-			// Allow ignored fields in the struct
-			if field.Tag.Get("form") == "-" {
+			// Allow ignored and unexported fields in the struct
+			if field.Tag.Get("form") == "-" || field.PkgPath != "" {
 				continue
 			}