summaryrefslogtreecommitdiff
path: root/vendor/github.com/go-playground/validator/v10/postcode_regexes.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/go-playground/validator/v10/postcode_regexes.go')
-rw-r--r--vendor/github.com/go-playground/validator/v10/postcode_regexes.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/vendor/github.com/go-playground/validator/v10/postcode_regexes.go b/vendor/github.com/go-playground/validator/v10/postcode_regexes.go
index e7e7b687f..326b8f753 100644
--- a/vendor/github.com/go-playground/validator/v10/postcode_regexes.go
+++ b/vendor/github.com/go-playground/validator/v10/postcode_regexes.go
@@ -1,6 +1,9 @@
package validator
-import "regexp"
+import (
+ "regexp"
+ "sync"
+)
var postCodePatternDict = map[string]string{
"GB": `^GIR[ ]?0AA|((AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)(\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}))|BFPO[ ]?\d{1,4}$`,
@@ -164,9 +167,12 @@ var postCodePatternDict = map[string]string{
"YT": `^976\d{2}$`,
}
-var postCodeRegexDict = map[string]*regexp.Regexp{}
+var (
+ postcodeRegexInit sync.Once
+ postCodeRegexDict = map[string]*regexp.Regexp{}
+)
-func init() {
+func initPostcodes() {
for countryCode, pattern := range postCodePatternDict {
postCodeRegexDict[countryCode] = regexp.MustCompile(pattern)
}