summaryrefslogtreecommitdiff
path: root/vendor/github.com/go-playground/validator/v10/validator_instance.go
diff options
context:
space:
mode:
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]