|
|
@ -161,15 +161,19 @@ func (v Validate) ValidateMapCtx(ctx context.Context, data map[string]interface{ |
|
|
|
if len(err) > 0 { |
|
|
|
if len(err) > 0 { |
|
|
|
errs[field] = err |
|
|
|
errs[field] = err |
|
|
|
} |
|
|
|
} |
|
|
|
} else if dataObjs, ok := data[field].([]map[string]interface{}); ok { |
|
|
|
} else { |
|
|
|
|
|
|
|
errs[field] = errors.New("The field: '" + field + "' is not a map to dive") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if arrRuleObj, ok := rule.([]map[string]interface{}); ok { |
|
|
|
|
|
|
|
if dataObjs, ok := data[field].([]map[string]interface{}); ok && len(arrRuleObj) > 0 { |
|
|
|
for _, obj := range dataObjs { |
|
|
|
for _, obj := range dataObjs { |
|
|
|
err := v.ValidateMapCtx(ctx, obj, ruleObj) |
|
|
|
err := v.ValidateMapCtx(ctx, obj, arrRuleObj[0]) |
|
|
|
if len(err) > 0 { |
|
|
|
if len(err) > 0 { |
|
|
|
errs[field] = err |
|
|
|
errs[field] = err |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
errs[field] = errors.New("The field: '" + field + "' is not a map to dive") |
|
|
|
errs[field] = errors.New("The field: '" + field + "' is not a map array") |
|
|
|
} |
|
|
|
} |
|
|
|
} else if ruleStr, ok := rule.(string); ok { |
|
|
|
} else if ruleStr, ok := rule.(string); ok { |
|
|
|
err := v.VarCtx(ctx, data[field], ruleStr) |
|
|
|
err := v.VarCtx(ctx, data[field], ruleStr) |
|
|
|