asaskevich / govalidator

[Go] Package of validators and sanitizers for strings, numerics, slices and structs
MIT License
6.05k stars 555 forks source link

the method ValidateStruct called tiwce when the field is Struct #291

Closed tangxiaodon89 closed 4 years ago

tangxiaodon89 commented 6 years ago

this is one please call the ValidateStruct if (valueField.Kind() == reflect.Struct || (valueField.Kind() == reflect.Ptr && valueField.Elem().Kind() == reflect.Struct)) && typeField.Tag.Get(tagName) != "-" { var err error structResult, err = ValidateStruct(valueField.Interface()) if err != nil { errs = append(errs, err) } }

and then this called typeCheck method resultField, err2 := typeCheck(valueField, typeField, val, nil) in the typeCheck mtehod called the ValidateStruct one more time case reflect.Struct: return ValidateStruct(v.Interface())

i get the validate error info like this. memory must not be null.;memory must not be null.;

asaskevich commented 4 years ago

Thank you for your investigation, it seems to be fixed in #330