A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
feat(validator): add notblank validation
LinkinStarec871efc752f
diff --git a/go.mod b/go.modindex 7c7aac21..5612516c 100644--- a/go.mod+++ b/go.mod@@ -5,6 +5,7 @@ go 1.18require (github.com/Chain-Zhang/pinyin v0.1.3github.com/anargu/gin-brotli v0.0.0-20220116052358-12bf532d5267+ github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8dgithub.com/bwmarrin/snowflake v0.3.0github.com/davecgh/go-spew v1.1.1github.com/disintegration/imaging v1.6.2@@ -55,7 +56,6 @@ require (github.com/Microsoft/go-winio v0.5.2 // indirectgithub.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirectgithub.com/andybalholm/brotli v1.0.4 // indirect- github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirectgithub.com/aymerick/douceur v0.2.0 // indirectgithub.com/cenkalti/backoff/v4 v4.1.3 // indirectgithub.com/containerd/continuity v0.3.0 // indirectdiff --git a/internal/base/validator/validator.go b/internal/base/validator/validator.goindex 8eae14e1..e88441fe 100644--- a/internal/base/validator/validator.go+++ b/internal/base/validator/validator.go@@ -23,6 +23,7 @@ import (chineseTraditional "github.com/go-playground/locales/zh_Hant_TW"ut "github.com/go-playground/universal-translator""github.com/go-playground/validator/v10"+ "github.com/go-playground/validator/v10/non-standard/validators""github.com/go-playground/validator/v10/translations/en""github.com/go-playground/validator/v10/translations/es""github.com/go-playground/validator/v10/translations/fr"@@ -99,6 +100,7 @@ func getTran(lo locales.Translator) ut.Translator {func createDefaultValidator(la i18n.Language) *validator.Validate {validate := validator.New()+ _ = validate.RegisterValidation("notblank", validators.NotBlank)validate.RegisterTagNameFunc(func(fld reflect.StructField) (res string) {defer func() {if len(res) > 0 {