From 882ec0def4aadc1386d7c87fee2348f8fa93745d Mon Sep 17 00:00:00 2001 From: Torwang <584197357@qq.com> Date: Tue, 6 Apr 2021 09:10:13 +0800 Subject: [PATCH] fix StructLevel Parent() (#716) Co-authored-by: torwang --- validator.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/validator.go b/validator.go index f097f39..9569c0d 100644 --- a/validator.go +++ b/validator.go @@ -74,7 +74,7 @@ func (v *validate) validateStruct(ctx context.Context, parent reflect.Value, cur } } - v.traverseField(ctx, parent, current.Field(f.idx), ns, structNs, f, f.cTags) + v.traverseField(ctx, current, current.Field(f.idx), ns, structNs, f, f.cTags) } } @@ -222,7 +222,7 @@ func (v *validate) traverseField(ctx context.Context, parent reflect.Value, curr structNs = append(append(structNs, cf.name...), '.') } - v.validateStruct(ctx, current, current, typ, ns, structNs, ct) + v.validateStruct(ctx, parent, current, typ, ns, structNs, ct) return } }