[fixed]:解决无法深层校验的bug #1283

This commit is contained in:
奇淼(piexlmax
2022-11-16 11:17:03 +08:00
parent 7bfad03b2e
commit 7540ee942f
2 changed files with 42 additions and 0 deletions
+5
View File
@@ -137,6 +137,11 @@ func Verify(st interface{}, roleMap Rules) (err error) {
for i := 0; i < num; i++ {
tagVal := typ.Field(i)
val := val.Field(i)
if tagVal.Type.Kind() == reflect.Struct {
if err = Verify(val.Interface(), roleMap); err != nil {
return err
}
}
if len(roleMap[tagVal.Name]) > 0 {
for _, v := range roleMap[tagVal.Name] {
switch {