diff --git a/validator_instance.go b/validator_instance.go index 8bd92cd..5bb9f5f 100644 --- a/validator_instance.go +++ b/validator_instance.go @@ -156,6 +156,9 @@ const omitemptyPrefix = "__omitempty__" // validation validation information via context.Context. func (v Validate) ValidateMapCtx(ctx context.Context, data map[string]interface{}, rules map[string]interface{}) map[string]interface{} { errs := make(map[string]interface{}) + if len(data) == 0 { + return errs + } Loop: for field, rule := range rules { if strings.HasPrefix(field, omitemptyPrefix) == true {