@@ -166,8 +166,6 @@ func (v *Validate) Struct(s interface{}) *StructErrors {
166166func (v * Validate ) structRecursive (top interface {}, current interface {}, s interface {}) * StructErrors {
167167
168168 structValue := reflect .ValueOf (s )
169- structType := reflect .TypeOf (s )
170- structName := structType .Name ()
171169
172170 if structValue .Kind () == reflect .Ptr && ! structValue .IsNil () {
173171 return v .structRecursive (top , current , structValue .Elem ().Interface ())
@@ -177,6 +175,9 @@ func (v *Validate) structRecursive(top interface{}, current interface{}, s inter
177175 panic ("interface passed for validation is not a struct" )
178176 }
179177
178+ structType := reflect .TypeOf (s )
179+ structName := structType .Name ()
180+
180181 validationErrors := & StructErrors {
181182 Struct : structName ,
182183 Errors : map [string ]* FieldError {},
@@ -339,7 +340,7 @@ func (v *Validate) fieldWithNameAndValue(val interface{}, current interface{}, f
339340func (v * Validate ) fieldWithNameAndSingleTag (val interface {}, current interface {}, f interface {}, name string , valTag string ) (* FieldError , error ) {
340341
341342 vals := strings .Split (valTag , tagKeySeparator )
342- key := strings .Trim (vals [0 ], " " )
343+ key := strings .TrimSpace (vals [0 ])
343344
344345 if len (key ) == 0 {
345346 panic (fmt .Sprintf ("Invalid validation tag on field %s" , name ))
@@ -364,7 +365,7 @@ func (v *Validate) fieldWithNameAndSingleTag(val interface{}, current interface{
364365
365366 param := ""
366367 if len (vals ) > 1 {
367- param = strings .Trim (vals [1 ], " " )
368+ param = strings .TrimSpace (vals [1 ])
368369 }
369370
370371 if err := valFunc (val , current , f , param ); ! err {
0 commit comments