@@ -25,13 +25,13 @@ type validate struct {
25
25
slflParent reflect.Value
26
26
slCurrent reflect.Value
27
27
slNs []byte
28
- slActualNs []byte
28
+ slStructNs []byte
29
29
flField reflect.Value
30
30
flParam string
31
31
}
32
32
33
33
// parent and current will be the same the first run of validateStruct
34
- func (v * validate ) validateStruct (parent reflect.Value , current reflect.Value , typ reflect.Type , ns []byte , actualNs []byte , ct * cTag ) {
34
+ func (v * validate ) validateStruct (parent reflect.Value , current reflect.Value , typ reflect.Type , ns []byte , structNs []byte , ct * cTag ) {
35
35
36
36
first := len (ns ) == 0
37
37
@@ -45,8 +45,8 @@ func (v *validate) validateStruct(parent reflect.Value, current reflect.Value, t
45
45
ns = append (ns , cs .Name ... )
46
46
ns = append (ns , '.' )
47
47
48
- actualNs = append (actualNs , cs .Name ... )
49
- actualNs = append (actualNs , '.' )
48
+ structNs = append (structNs , cs .Name ... )
49
+ structNs = append (structNs , '.' )
50
50
}
51
51
52
52
// ct is nil on top level struct, and structs as fields that have no tag info
@@ -64,7 +64,7 @@ func (v *validate) validateStruct(parent reflect.Value, current reflect.Value, t
64
64
}
65
65
}
66
66
67
- v .traverseField (parent , current .Field (f .Idx ), ns , actualNs , f , f .cTags )
67
+ v .traverseField (parent , current .Field (f .Idx ), ns , structNs , f , f .cTags )
68
68
}
69
69
}
70
70
@@ -76,14 +76,14 @@ func (v *validate) validateStruct(parent reflect.Value, current reflect.Value, t
76
76
v .slflParent = parent
77
77
v .slCurrent = current
78
78
v .slNs = ns
79
- v .slActualNs = actualNs
79
+ v .slStructNs = structNs
80
80
81
81
cs .fn (v )
82
82
}
83
83
}
84
84
85
85
// traverseField validates any field, be it a struct or single field, ensures it's validity and passes it along to be validated via it's tag options
86
- func (v * validate ) traverseField (parent reflect.Value , current reflect.Value , ns []byte , actualNs []byte , cf * cField , ct * cTag ) {
86
+ func (v * validate ) traverseField (parent reflect.Value , current reflect.Value , ns []byte , structNs []byte , cf * cField , ct * cTag ) {
87
87
88
88
var typ reflect.Type
89
89
var kind reflect.Kind
@@ -111,9 +111,9 @@ func (v *validate) traverseField(parent reflect.Value, current reflect.Value, ns
111
111
tag : ct .aliasTag ,
112
112
actualTag : ct .tag ,
113
113
ns : string (append (ns , cf .Name ... )),
114
- actualNs : string (append (actualNs , cf .AltName ... )),
114
+ structNs : string (append (structNs , cf .AltName ... )),
115
115
field : cf .AltName ,
116
- actualField : cf .Name ,
116
+ structField : cf .Name ,
117
117
param : ct .param ,
118
118
kind : kind ,
119
119
},
@@ -127,9 +127,9 @@ func (v *validate) traverseField(parent reflect.Value, current reflect.Value, ns
127
127
tag : ct .aliasTag ,
128
128
actualTag : ct .tag ,
129
129
ns : string (append (ns , cf .Name ... )),
130
- actualNs : string (append (actualNs , cf .AltName ... )),
130
+ structNs : string (append (structNs , cf .AltName ... )),
131
131
field : cf .AltName ,
132
- actualField : cf .Name ,
132
+ structField : cf .Name ,
133
133
value : current .Interface (),
134
134
param : ct .param ,
135
135
kind : kind ,
@@ -154,7 +154,7 @@ func (v *validate) traverseField(parent reflect.Value, current reflect.Value, ns
154
154
return
155
155
}
156
156
157
- v .validateStruct (current , current , typ , append (append (ns , cf .Name ... ), '.' ), append (append (actualNs , cf .AltName ... ), '.' ), ct )
157
+ v .validateStruct (current , current , typ , append (append (ns , cf .Name ... ), '.' ), append (append (structNs , cf .AltName ... ), '.' ), ct )
158
158
return
159
159
}
160
160
}
@@ -201,12 +201,12 @@ OUTER:
201
201
case reflect .Slice , reflect .Array :
202
202
203
203
for i := 0 ; i < current .Len (); i ++ {
204
- v .traverseField (parent , current .Index (i ), ns , actualNs , & cField {Name : fmt .Sprintf (arrayIndexFieldName , cf .Name , i ), AltName : fmt .Sprintf (arrayIndexFieldName , cf .AltName , i )}, ct )
204
+ v .traverseField (parent , current .Index (i ), ns , structNs , & cField {Name : fmt .Sprintf (arrayIndexFieldName , cf .Name , i ), AltName : fmt .Sprintf (arrayIndexFieldName , cf .AltName , i )}, ct )
205
205
}
206
206
207
207
case reflect .Map :
208
208
for _ , key := range current .MapKeys () {
209
- v .traverseField (parent , current .MapIndex (key ), ns , actualNs , & cField {Name : fmt .Sprintf (mapIndexFieldName , cf .Name , key .Interface ()), AltName : fmt .Sprintf (mapIndexFieldName , cf .AltName , key .Interface ())}, ct )
209
+ v .traverseField (parent , current .MapIndex (key ), ns , structNs , & cField {Name : fmt .Sprintf (mapIndexFieldName , cf .Name , key .Interface ()), AltName : fmt .Sprintf (mapIndexFieldName , cf .AltName , key .Interface ())}, ct )
210
210
}
211
211
212
212
default :
@@ -257,9 +257,9 @@ OUTER:
257
257
tag : ct .aliasTag ,
258
258
actualTag : ct .actualAliasTag ,
259
259
ns : string (append (ns , cf .Name ... )),
260
- actualNs : string (append (actualNs , cf .AltName ... )),
260
+ structNs : string (append (structNs , cf .AltName ... )),
261
261
field : cf .AltName ,
262
- actualField : cf .Name ,
262
+ structField : cf .Name ,
263
263
value : current .Interface (),
264
264
param : ct .param ,
265
265
kind : kind ,
@@ -274,9 +274,9 @@ OUTER:
274
274
tag : errTag [1 :],
275
275
actualTag : errTag [1 :],
276
276
ns : string (append (ns , cf .Name ... )),
277
- actualNs : string (append (actualNs , cf .AltName ... )),
277
+ structNs : string (append (structNs , cf .AltName ... )),
278
278
field : cf .AltName ,
279
- actualField : cf .Name ,
279
+ structField : cf .Name ,
280
280
value : current .Interface (),
281
281
param : ct .param ,
282
282
kind : kind ,
@@ -305,9 +305,9 @@ OUTER:
305
305
tag : ct .aliasTag ,
306
306
actualTag : ct .tag ,
307
307
ns : string (append (ns , cf .Name ... )),
308
- actualNs : string (append (actualNs , cf .AltName ... )),
308
+ structNs : string (append (structNs , cf .AltName ... )),
309
309
field : cf .AltName ,
310
- actualField : cf .Name ,
310
+ structField : cf .Name ,
311
311
value : current .Interface (),
312
312
param : ct .param ,
313
313
kind : kind ,
0 commit comments