v9
Question
I'm using func (*Validate) Struct to validate API requests.
Is that safe to use only one instance of Validate for the whole project considering there may be simultaneous calls to (*Validate) Struct()?
Hey @7fELF great question
And the answer is yes it is completely thread/goroutine safe and is designed to be used with a single instance. Validator also caches information about your struct and validations, in essence only parsing your validation tags once per struct type, without a single instance you wouldn鈥檛 get the advantages of the cache.
Thanks for the quick answer :smile:
Most helpful comment
Hey @7fELF great question
And the answer is yes it is completely thread/goroutine safe and is designed to be used with a single instance. Validator also caches information about your struct and validations, in essence only parsing your validation tags once per struct type, without a single instance you wouldn鈥檛 get the advantages of the cache.