File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,9 @@ func Struct(structure interface{}) error {
56
56
// recurse if this is an embedded struct
57
57
if value .Kind () == reflect .Struct && field .PkgPath == "" {
58
58
// only exported fields should do this
59
- return Struct (value .Interface ())
59
+ if err := Struct (value .Interface ()); err != nil {
60
+ return err
61
+ }
60
62
}
61
63
62
64
// get all the v tags
Original file line number Diff line number Diff line change @@ -130,6 +130,25 @@ func TestStruct(t *testing.T) {
130
130
}
131
131
}
132
132
133
+ func Test_Embedding (t * testing.T ) {
134
+ type A struct {
135
+ StrField string `v:"between:0..10"`
136
+ }
137
+ type B struct {
138
+ A
139
+ IntField int `v:"between:0..10"`
140
+ }
141
+ err := Struct (B {
142
+ A : A {
143
+ StrField : "hello world!" , // this is not ok
144
+ },
145
+ IntField : 10 , // this is ok
146
+ })
147
+ if err == nil {
148
+ t .Error ("This should fail" )
149
+ }
150
+ }
151
+
133
152
func Test_validationErorrs_Error (t * testing.T ) {
134
153
tests := []struct {
135
154
name string
You can’t perform that action at this time.
0 commit comments