summaryrefslogtreecommitdiff
path: root/vendor/github.com/go-playground/validator/v10/validator_instance.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-09-10 14:42:14 +0200
committerLibravatar GitHub <noreply@github.com>2021-09-10 14:42:14 +0200
commitf2e5bedea6fb93fbbf68ed8f7153c353cc57a9f0 (patch)
tree475ae9e7470d0df670ab2a59dce351cd1d07498a /vendor/github.com/go-playground/validator/v10/validator_instance.go
parentfixes + db changes (#204) (diff)
downloadgotosocial-f2e5bedea6fb93fbbf68ed8f7153c353cc57a9f0.tar.xz
migrate go version to 1.17 (#203)
* migrate go version to 1.17 * update contributing
Diffstat (limited to 'vendor/github.com/go-playground/validator/v10/validator_instance.go')
-rw-r--r--vendor/github.com/go-playground/validator/v10/validator_instance.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/vendor/github.com/go-playground/validator/v10/validator_instance.go b/vendor/github.com/go-playground/validator/v10/validator_instance.go
index 8e27707ea..973964fc2 100644
--- a/vendor/github.com/go-playground/validator/v10/validator_instance.go
+++ b/vendor/github.com/go-playground/validator/v10/validator_instance.go
@@ -89,6 +89,10 @@ type Validate struct {
}
// New returns a new instance of 'validate' with sane defaults.
+// Validate is designed to be thread-safe and used as a singleton instance.
+// It caches information about your struct and validations,
+// in essence only parsing your validation tags once per struct type.
+// Using multiple instances neglects the benefit of caching.
func New() *Validate {
tc := new(tagCache)
@@ -207,11 +211,11 @@ func (v *Validate) RegisterValidationCtx(tag string, fn FuncCtx, callValidationE
func (v *Validate) registerValidation(tag string, fn FuncCtx, bakedIn bool, nilCheckable bool) error {
if len(tag) == 0 {
- return errors.New("Function Key cannot be empty")
+ return errors.New("function Key cannot be empty")
}
if fn == nil {
- return errors.New("Function cannot be empty")
+ return errors.New("function cannot be empty")
}
_, ok := restrictedTags[tag]