File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,14 @@ and has the ability to dive into arrays and maps of any type.
77
88see more examples https://github.com/go-playground/validator/tree/master/_examples
99
10+ Singleton
11+
12+ Validator is designed to be thread-safe and used as a singleton instance.
13+ It caches information about your struct and validations,
14+ in essence only parsing your validation tags once per struct type.
15+ Using multiple instances neglects the benefit of caching.
16+ The not thread-safe functions are explicitly marked as such in the documentation.
17+
1018Validation Functions Return Type error
1119
1220Doing things this way is actually the way the standard library does, see the
Original file line number Diff line number Diff line change @@ -89,6 +89,10 @@ type Validate struct {
8989}
9090
9191// New returns a new instance of 'validate' with sane defaults.
92+ // Validate is designed to be thread-safe and used as a singleton instance.
93+ // It caches information about your struct and validations,
94+ // in essence only parsing your validation tags once per struct type.
95+ // Using multiple instances neglects the benefit of caching.
9296func New () * Validate {
9397
9498 tc := new (tagCache )
You can’t perform that action at this time.
0 commit comments