diff --git a/_examples/custom-validation/main.go b/_examples/custom-validation/main.go index 6ba8ef2..b956e68 100644 --- a/_examples/custom-validation/main.go +++ b/_examples/custom-validation/main.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "github.com/go-playground/validator/v10" + "gitea.drugeyes.vip/pharnexbase/validator/v10" ) // MyStruct .. diff --git a/_examples/custom/main.go b/_examples/custom/main.go index f44ef4c..19a878d 100644 --- a/_examples/custom/main.go +++ b/_examples/custom/main.go @@ -6,7 +6,7 @@ import ( "fmt" "reflect" - "github.com/go-playground/validator/v10" + "gitea.drugeyes.vip/pharnexbase/validator/v10" ) // DbBackedUser User struct diff --git a/_examples/dive/main.go b/_examples/dive/main.go index 18b9e7f..de6e404 100644 --- a/_examples/dive/main.go +++ b/_examples/dive/main.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "github.com/go-playground/validator/v10" + "gitea.drugeyes.vip/pharnexbase/validator/v10" ) // Test ... diff --git a/_examples/gin-upgrading-overriding/v8_to_v9.go b/_examples/gin-upgrading-overriding/v8_to_v9.go index 8c310a7..94b3312 100644 --- a/_examples/gin-upgrading-overriding/v8_to_v9.go +++ b/_examples/gin-upgrading-overriding/v8_to_v9.go @@ -4,8 +4,8 @@ import ( "reflect" "sync" + "gitea.drugeyes.vip/pharnexbase/validator/v10" "github.com/gin-gonic/gin/binding" - "github.com/go-playground/validator/v10" ) type defaultValidator struct { diff --git a/_examples/map-validation/main.go b/_examples/map-validation/main.go index dfcfa4f..cc44178 100644 --- a/_examples/map-validation/main.go +++ b/_examples/map-validation/main.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "github.com/go-playground/validator/v10" + "gitea.drugeyes.vip/pharnexbase/validator/v10" ) var validate *validator.Validate diff --git a/_examples/simple/main.go b/_examples/simple/main.go index 0d3ca51..8f353f6 100644 --- a/_examples/simple/main.go +++ b/_examples/simple/main.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "github.com/go-playground/validator/v10" + "gitea.drugeyes.vip/pharnexbase/validator/v10" ) // User contains user information diff --git a/_examples/struct-level/main.go b/_examples/struct-level/main.go index a16cf4e..6eeb618 100644 --- a/_examples/struct-level/main.go +++ b/_examples/struct-level/main.go @@ -6,7 +6,7 @@ import ( "reflect" "strings" - "github.com/go-playground/validator/v10" + "gitea.drugeyes.vip/pharnexbase/validator/v10" ) type validationError struct { diff --git a/_examples/struct-map-rules-validation/main.go b/_examples/struct-map-rules-validation/main.go index e936117..cf001fa 100644 --- a/_examples/struct-map-rules-validation/main.go +++ b/_examples/struct-map-rules-validation/main.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "github.com/go-playground/validator/v10" + "gitea.drugeyes.vip/pharnexbase/validator/v10" ) type Data struct { diff --git a/_examples/translations/main.go b/_examples/translations/main.go index 6f9466d..3cde011 100644 --- a/_examples/translations/main.go +++ b/_examples/translations/main.go @@ -3,10 +3,10 @@ package main import ( "fmt" + "gitea.drugeyes.vip/pharnexbase/validator/v10" + en_translations "gitea.drugeyes.vip/pharnexbase/validator/v10/translations/en" "github.com/go-playground/locales/en" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" - en_translations "github.com/go-playground/validator/v10/translations/en" ) // User contains user information diff --git a/go.mod b/go.mod index aa7527d..5c34d93 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/go-playground/validator/v10 +module gitea.drugeyes.vip/pharnexbase/validator/v10 go 1.18 diff --git a/non-standard/validators/notblank.go b/non-standard/validators/notblank.go index 2867243..92eb538 100644 --- a/non-standard/validators/notblank.go +++ b/non-standard/validators/notblank.go @@ -4,7 +4,7 @@ import ( "reflect" "strings" - "github.com/go-playground/validator/v10" + "gitea.drugeyes.vip/pharnexbase/validator/v10" ) // NotBlank is the validation function for validating if the current field diff --git a/non-standard/validators/notblank_test.go b/non-standard/validators/notblank_test.go index 96c6720..d3c6097 100644 --- a/non-standard/validators/notblank_test.go +++ b/non-standard/validators/notblank_test.go @@ -3,8 +3,8 @@ package validators import ( "testing" + "gitea.drugeyes.vip/pharnexbase/validator/v10" "github.com/go-playground/assert/v2" - "github.com/go-playground/validator/v10" ) type test struct { diff --git a/translations/ar/ar.go b/translations/ar/ar.go index 3886120..a791f62 100644 --- a/translations/ar/ar.go +++ b/translations/ar/ar.go @@ -8,9 +8,9 @@ import ( "strings" "time" + "gitea.drugeyes.vip/pharnexbase/validator/v10" "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/ar/ar_test.go b/translations/ar/ar_test.go index 93adfe9..dc098c9 100644 --- a/translations/ar/ar_test.go +++ b/translations/ar/ar_test.go @@ -4,10 +4,10 @@ import ( "testing" "time" + "gitea.drugeyes.vip/pharnexbase/validator/v10" . "github.com/go-playground/assert/v2" english "github.com/go-playground/locales/en" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/translations/en/en.go b/translations/en/en.go index 486c95e..542dfc0 100644 --- a/translations/en/en.go +++ b/translations/en/en.go @@ -8,9 +8,9 @@ import ( "strings" "time" + "gitea.drugeyes.vip/pharnexbase/validator/v10" "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/en/en_test.go b/translations/en/en_test.go index df07897..616604d 100644 --- a/translations/en/en_test.go +++ b/translations/en/en_test.go @@ -4,10 +4,10 @@ import ( "testing" "time" + "gitea.drugeyes.vip/pharnexbase/validator/v10" . "github.com/go-playground/assert/v2" english "github.com/go-playground/locales/en" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/translations/es/es.go b/translations/es/es.go index 73b06cf..049259a 100644 --- a/translations/es/es.go +++ b/translations/es/es.go @@ -8,9 +8,9 @@ import ( "strings" "time" + "gitea.drugeyes.vip/pharnexbase/validator/v10" "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/es/es_test.go b/translations/es/es_test.go index c2c4c81..b390f9b 100644 --- a/translations/es/es_test.go +++ b/translations/es/es_test.go @@ -4,10 +4,10 @@ import ( "testing" "time" + "gitea.drugeyes.vip/pharnexbase/validator/v10" . "github.com/go-playground/assert/v2" spanish "github.com/go-playground/locales/es" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/translations/fa/fa.go b/translations/fa/fa.go index b7c100b..2079b11 100644 --- a/translations/fa/fa.go +++ b/translations/fa/fa.go @@ -8,9 +8,9 @@ import ( "strings" "time" + "gitea.drugeyes.vip/pharnexbase/validator/v10" "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/fa/fa_test.go b/translations/fa/fa_test.go index 1acb8cf..ed5ee5a 100644 --- a/translations/fa/fa_test.go +++ b/translations/fa/fa_test.go @@ -4,10 +4,10 @@ import ( "testing" "time" + "gitea.drugeyes.vip/pharnexbase/validator/v10" . "github.com/go-playground/assert/v2" english "github.com/go-playground/locales/en" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/translations/fr/fr.go b/translations/fr/fr.go index c455195..7714c45 100644 --- a/translations/fr/fr.go +++ b/translations/fr/fr.go @@ -8,9 +8,9 @@ import ( "strings" "time" + "gitea.drugeyes.vip/pharnexbase/validator/v10" "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/fr/fr_test.go b/translations/fr/fr_test.go index f1ba280..d19cdd3 100644 --- a/translations/fr/fr_test.go +++ b/translations/fr/fr_test.go @@ -4,10 +4,10 @@ import ( "testing" "time" + "gitea.drugeyes.vip/pharnexbase/validator/v10" . "github.com/go-playground/assert/v2" french "github.com/go-playground/locales/fr" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/translations/id/id.go b/translations/id/id.go index 08b6ad5..30aec7e 100644 --- a/translations/id/id.go +++ b/translations/id/id.go @@ -8,9 +8,9 @@ import ( "strings" "time" + "gitea.drugeyes.vip/pharnexbase/validator/v10" "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/id/id_test.go b/translations/id/id_test.go index 5d80940..96bec27 100644 --- a/translations/id/id_test.go +++ b/translations/id/id_test.go @@ -4,10 +4,10 @@ import ( "testing" "time" + "gitea.drugeyes.vip/pharnexbase/validator/v10" . "github.com/go-playground/assert/v2" indonesia "github.com/go-playground/locales/id" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/translations/it/it.go b/translations/it/it.go index 8f999a4..023cb94 100644 --- a/translations/it/it.go +++ b/translations/it/it.go @@ -2,6 +2,7 @@ package it import ( "fmt" + "gitea.drugeyes.vip/pharnexbase/validator/v10" "log" "reflect" "strconv" @@ -10,7 +11,6 @@ import ( "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/it/it_test.go b/translations/it/it_test.go index 98d2ab5..8d225bd 100644 --- a/translations/it/it_test.go +++ b/translations/it/it_test.go @@ -1,13 +1,13 @@ package it import ( + "gitea.drugeyes.vip/pharnexbase/validator/v10" "testing" "time" . "github.com/go-playground/assert/v2" italian "github.com/go-playground/locales/it" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/translations/ja/ja.go b/translations/ja/ja.go index cdc2934..995e7d5 100644 --- a/translations/ja/ja.go +++ b/translations/ja/ja.go @@ -10,7 +10,6 @@ import ( "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/ja/ja_test.go b/translations/ja/ja_test.go index 56e14cf..a86abf0 100644 --- a/translations/ja/ja_test.go +++ b/translations/ja/ja_test.go @@ -1,13 +1,13 @@ package ja import ( + "gitea.drugeyes.vip/pharnexbase/validator/v10" "testing" "time" . "github.com/go-playground/assert/v2" ja_locale "github.com/go-playground/locales/ja" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/translations/lv/lv.go b/translations/lv/lv.go index 0804ff3..27c0c8a 100644 --- a/translations/lv/lv.go +++ b/translations/lv/lv.go @@ -2,6 +2,7 @@ package lv import ( "fmt" + "gitea.drugeyes.vip/pharnexbase/validator/v10" "log" "reflect" "strconv" @@ -10,7 +11,6 @@ import ( "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/lv/lv_test.go b/translations/lv/lv_test.go index ca99784..b45aa68 100644 --- a/translations/lv/lv_test.go +++ b/translations/lv/lv_test.go @@ -1,13 +1,13 @@ package lv import ( + "gitea.drugeyes.vip/pharnexbase/validator/v10" "testing" "time" . "github.com/go-playground/assert/v2" english "github.com/go-playground/locales/en" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/translations/nl/nl.go b/translations/nl/nl.go index ca7c554..0a98d3d 100644 --- a/translations/nl/nl.go +++ b/translations/nl/nl.go @@ -10,7 +10,6 @@ import ( "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/nl/nl_test.go b/translations/nl/nl_test.go index 137e0c4..2517546 100644 --- a/translations/nl/nl_test.go +++ b/translations/nl/nl_test.go @@ -1,13 +1,13 @@ package nl import ( + "gitea.drugeyes.vip/pharnexbase/validator/v10" "testing" "time" . "github.com/go-playground/assert/v2" english "github.com/go-playground/locales/en" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/translations/pt/pt.go b/translations/pt/pt.go index 4748331..b0e9f9e 100644 --- a/translations/pt/pt.go +++ b/translations/pt/pt.go @@ -10,7 +10,6 @@ import ( "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/pt/pt_test.go b/translations/pt/pt_test.go index 0422ab0..4d53e2a 100644 --- a/translations/pt/pt_test.go +++ b/translations/pt/pt_test.go @@ -1,14 +1,13 @@ package pt import ( + "gitea.drugeyes.vip/pharnexbase/validator/v10" "testing" "time" . "github.com/go-playground/assert/v2" "github.com/go-playground/locales/pt" ut "github.com/go-playground/universal-translator" - - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/translations/pt_BR/pt_BR.go b/translations/pt_BR/pt_BR.go index 91488e5..f6deeb8 100644 --- a/translations/pt_BR/pt_BR.go +++ b/translations/pt_BR/pt_BR.go @@ -2,6 +2,7 @@ package pt_BR import ( "fmt" + "gitea.drugeyes.vip/pharnexbase/validator/v10" "log" "reflect" "strconv" @@ -10,7 +11,6 @@ import ( "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/pt_BR/pt_BR_test.go b/translations/pt_BR/pt_BR_test.go index b149e1d..8a01c45 100644 --- a/translations/pt_BR/pt_BR_test.go +++ b/translations/pt_BR/pt_BR_test.go @@ -1,13 +1,13 @@ package pt_BR import ( + "gitea.drugeyes.vip/pharnexbase/validator/v10" "testing" "time" . "github.com/go-playground/assert/v2" brazilian_portuguese "github.com/go-playground/locales/pt_BR" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/translations/ru/ru.go b/translations/ru/ru.go index 25400c5..f2d5920 100644 --- a/translations/ru/ru.go +++ b/translations/ru/ru.go @@ -2,6 +2,7 @@ package ru import ( "fmt" + "gitea.drugeyes.vip/pharnexbase/validator/v10" "log" "reflect" "strconv" @@ -10,7 +11,6 @@ import ( "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/ru/ru_test.go b/translations/ru/ru_test.go index c74f0d5..d1b57f9 100644 --- a/translations/ru/ru_test.go +++ b/translations/ru/ru_test.go @@ -1,6 +1,7 @@ package ru import ( + "gitea.drugeyes.vip/pharnexbase/validator/v10" "log" //"github.com/rustery/validator" "testing" @@ -9,7 +10,6 @@ import ( . "github.com/go-playground/assert/v2" russian "github.com/go-playground/locales/ru" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/translations/tr/tr.go b/translations/tr/tr.go index 2e88a20..1d11167 100644 --- a/translations/tr/tr.go +++ b/translations/tr/tr.go @@ -2,6 +2,7 @@ package tr import ( "fmt" + "gitea.drugeyes.vip/pharnexbase/validator/v10" "log" "reflect" "strconv" @@ -10,7 +11,6 @@ import ( "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/tr/tr_test.go b/translations/tr/tr_test.go index b72329e..becec23 100644 --- a/translations/tr/tr_test.go +++ b/translations/tr/tr_test.go @@ -1,13 +1,13 @@ package tr import ( + "gitea.drugeyes.vip/pharnexbase/validator/v10" "testing" "time" . "github.com/go-playground/assert/v2" turkish "github.com/go-playground/locales/tr" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/translations/vi/vi.go b/translations/vi/vi.go index 009ba4c..f1feeee 100644 --- a/translations/vi/vi.go +++ b/translations/vi/vi.go @@ -10,7 +10,6 @@ import ( "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/vi/vi_test.go b/translations/vi/vi_test.go index 6e12866..c487cb8 100644 --- a/translations/vi/vi_test.go +++ b/translations/vi/vi_test.go @@ -1,13 +1,13 @@ package vi import ( + "gitea.drugeyes.vip/pharnexbase/validator/v10" "testing" "time" . "github.com/go-playground/assert/v2" vietnamese "github.com/go-playground/locales/vi" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/translations/zh/zh.go b/translations/zh/zh.go index 80165d0..11c2119 100644 --- a/translations/zh/zh.go +++ b/translations/zh/zh.go @@ -2,6 +2,7 @@ package zh import ( "fmt" + "gitea.drugeyes.vip/pharnexbase/validator/v10" "log" "reflect" "strconv" @@ -10,7 +11,6 @@ import ( "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/zh/zh_test.go b/translations/zh/zh_test.go index cf76590..7594d91 100644 --- a/translations/zh/zh_test.go +++ b/translations/zh/zh_test.go @@ -1,13 +1,13 @@ package zh import ( + "gitea.drugeyes.vip/pharnexbase/validator/v10" "testing" "time" . "github.com/go-playground/assert/v2" zhongwen "github.com/go-playground/locales/zh" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/translations/zh_tw/zh_tw.go b/translations/zh_tw/zh_tw.go index c39a8d7..6a891b4 100644 --- a/translations/zh_tw/zh_tw.go +++ b/translations/zh_tw/zh_tw.go @@ -10,7 +10,6 @@ import ( "github.com/go-playground/locales" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) // RegisterDefaultTranslations registers a set of default translations diff --git a/translations/zh_tw/zh_tw_test.go b/translations/zh_tw/zh_tw_test.go index 129c51a..313a267 100644 --- a/translations/zh_tw/zh_tw_test.go +++ b/translations/zh_tw/zh_tw_test.go @@ -1,13 +1,13 @@ package zh_tw import ( + "gitea.drugeyes.vip/pharnexbase/validator/v10" "testing" "time" . "github.com/go-playground/assert/v2" zhongwen "github.com/go-playground/locales/zh_Hant_TW" ut "github.com/go-playground/universal-translator" - "github.com/go-playground/validator/v10" ) func TestTranslations(t *testing.T) { diff --git a/validator_instance.go b/validator_instance.go index 51ae1aa..7d73711 100644 --- a/validator_instance.go +++ b/validator_instance.go @@ -161,15 +161,19 @@ func (v Validate) ValidateMapCtx(ctx context.Context, data map[string]interface{ if len(err) > 0 { 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 { - err := v.ValidateMapCtx(ctx, obj, ruleObj) + err := v.ValidateMapCtx(ctx, obj, arrRuleObj[0]) if len(err) > 0 { errs[field] = err } } } 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 { err := v.VarCtx(ctx, data[field], ruleStr)