Jelajahi Sumber

Validate should ignore unexported struct fields.

Andrey Smirnov 11 tahun lalu
induk
melakukan
e36f2945bb
1 mengubah file dengan 2 tambahan dan 2 penghapusan
  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
 			}