[](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-
+
[](https://travis-ci.org/go-playground/validator)
[](https://coveralls.io/github/go-playground/validator?branch=master)
[](https://goreportcard.com/report/github.com/go-playground/validator)
diff --git a/vendor/github.com/go-playground/validator/v10/baked_in.go b/vendor/github.com/go-playground/validator/v10/baked_in.go
index 58a1470b..b6fbaafa 100644
--- a/vendor/github.com/go-playground/validator/v10/baked_in.go
+++ b/vendor/github.com/go-playground/validator/v10/baked_in.go
@@ -253,7 +253,7 @@ func parseOneOfParam2(s string) []string {
oneofValsCacheRWLock.RUnlock()
if !ok {
oneofValsCacheRWLock.Lock()
- vals = splitParamsRegex.FindAllString(s, -1)
+ vals = splitParamsRegex().FindAllString(s, -1)
for i := 0; i < len(vals); i++ {
vals[i] = strings.Replace(vals[i], "'", "", -1)
}
@@ -264,15 +264,15 @@ func parseOneOfParam2(s string) []string {
}
func isURLEncoded(fl FieldLevel) bool {
- return uRLEncodedRegex.MatchString(fl.Field().String())
+ return uRLEncodedRegex().MatchString(fl.Field().String())
}
func isHTMLEncoded(fl FieldLevel) bool {
- return hTMLEncodedRegex.MatchString(fl.Field().String())
+ return hTMLEncodedRegex().MatchString(fl.Field().String())
}
func isHTML(fl FieldLevel) bool {
- return hTMLRegex.MatchString(fl.Field().String())
+ return hTMLRegex().MatchString(fl.Field().String())
}
func isOneOf(fl FieldLevel) bool {
@@ -429,7 +429,7 @@ func isSSN(fl FieldLevel) bool {
return false
}
- return sSNRegex.MatchString(field.String())
+ return sSNRegex().MatchString(field.String())
}
// isLongitude is the validation function for validating if the field's value is a valid longitude coordinate.
@@ -452,7 +452,7 @@ func isLongitude(fl FieldLevel) bool {
panic(fmt.Sprintf("Bad field type %T", field.Interface()))
}
- return longitudeRegex.MatchString(v)
+ return longitudeRegex().MatchString(v)
}
// isLatitude is the validation function for validating if the field's value is a valid latitude coordinate.
@@ -475,7 +475,7 @@ func isLatitude(fl FieldLevel) bool {
panic(fmt.Sprintf("Bad field type %T", field.Interface()))
}
- return latitudeRegex.MatchString(v)
+ return latitudeRegex().MatchString(v)
}
// isDataURI is the validation function for validating if the field's value is a valid data URI.
@@ -486,11 +486,11 @@ func isDataURI(fl FieldLevel) bool {
return false
}
- if !dataURIRegex.MatchString(uri[0]) {
+ if !dataURIRegex().MatchString(uri[0]) {
return false
}
- return base64Regex.MatchString(uri[1])
+ return base64Regex().MatchString(uri[1])
}
// hasMultiByteCharacter is the validation function for validating if the field's value has a multi byte character.
@@ -501,17 +501,17 @@ func hasMultiByteCharacter(fl FieldLevel) bool {
return true
}
- return multibyteRegex.MatchString(field.String())
+ return multibyteRegex().MatchString(field.String())
}
// isPrintableASCII is the validation function for validating if the field's value is a valid printable ASCII character.
func isPrintableASCII(fl FieldLevel) bool {
- return printableASCIIRegex.MatchString(fl.Field().String())
+ return printableASCIIRegex().MatchString(fl.Field().String())
}
// isASCII is the validation function for validating if the field's value is a valid ASCII character.
func isASCII(fl FieldLevel) bool {
- return aSCIIRegex.MatchString(fl.Field().String())
+ return aSCIIRegex().MatchString(fl.Field().String())
}
// isUUID5 is the validation function for validating if the field's value is a valid v5 UUID.
@@ -561,52 +561,52 @@ func isULID(fl FieldLevel) bool {
// isMD4 is the validation function for validating if the field's value is a valid MD4.
func isMD4(fl FieldLevel) bool {
- return md4Regex.MatchString(fl.Field().String())
+ return md4Regex().MatchString(fl.Field().String())
}
// isMD5 is the validation function for validating if the field's value is a valid MD5.
func isMD5(fl FieldLevel) bool {
- return md5Regex.MatchString(fl.Field().String())
+ return md5Regex().MatchString(fl.Field().String())
}
// isSHA256 is the validation function for validating if the field's value is a valid SHA256.
func isSHA256(fl FieldLevel) bool {
- return sha256Regex.MatchString(fl.Field().String())
+ return sha256Regex().MatchString(fl.Field().String())
}
// isSHA384 is the validation function for validating if the field's value is a valid SHA384.
func isSHA384(fl FieldLevel) bool {
- return sha384Regex.MatchString(fl.Field().String())
+ return sha384Regex().MatchString(fl.Field().String())
}
// isSHA512 is the validation function for validating if the field's value is a valid SHA512.
func isSHA512(fl FieldLevel) bool {
- return sha512Regex.MatchString(fl.Field().String())
+ return sha512Regex().MatchString(fl.Field().String())
}
// isRIPEMD128 is the validation function for validating if the field's value is a valid PIPEMD128.
func isRIPEMD128(fl FieldLevel) bool {
- return ripemd128Regex.MatchString(fl.Field().String())
+ return ripemd128Regex().MatchString(fl.Field().String())
}
// isRIPEMD160 is the validation function for validating if the field's value is a valid PIPEMD160.
func isRIPEMD160(fl FieldLevel) bool {
- return ripemd160Regex.MatchString(fl.Field().String())
+ return ripemd160Regex().MatchString(fl.Field().String())
}
// isTIGER128 is the validation function for validating if the field's value is a valid TIGER128.
func isTIGER128(fl FieldLevel) bool {
- return tiger128Regex.MatchString(fl.Field().String())
+ return tiger128Regex().MatchString(fl.Field().String())
}
// isTIGER160 is the validation function for validating if the field's value is a valid TIGER160.
func isTIGER160(fl FieldLevel) bool {
- return tiger160Regex.MatchString(fl.Field().String())
+ return tiger160Regex().MatchString(fl.Field().String())
}
// isTIGER192 is the validation function for validating if the field's value is a valid isTIGER192.
func isTIGER192(fl FieldLevel) bool {
- return tiger192Regex.MatchString(fl.Field().String())
+ return tiger192Regex().MatchString(fl.Field().String())
}
// isISBN is the validation function for validating if the field's value is a valid v10 or v13 ISBN.
@@ -618,7 +618,7 @@ func isISBN(fl FieldLevel) bool {
func isISBN13(fl FieldLevel) bool {
s := strings.Replace(strings.Replace(fl.Field().String(), "-", "", 4), " ", "", 4)
- if !iSBN13Regex.MatchString(s) {
+ if !iSBN13Regex().MatchString(s) {
return false
}
@@ -638,7 +638,7 @@ func isISBN13(fl FieldLevel) bool {
func isISBN10(fl FieldLevel) bool {
s := strings.Replace(strings.Replace(fl.Field().String(), "-", "", 3), " ", "", 3)
- if !iSBN10Regex.MatchString(s) {
+ if !iSBN10Regex().MatchString(s) {
return false
}
@@ -662,7 +662,7 @@ func isISBN10(fl FieldLevel) bool {
func isISSN(fl FieldLevel) bool {
s := fl.Field().String()
- if !iSSNRegex.MatchString(s) {
+ if !iSSNRegex().MatchString(s) {
return false
}
s = strings.ReplaceAll(s, "-", "")
@@ -688,14 +688,14 @@ func isISSN(fl FieldLevel) bool {
func isEthereumAddress(fl FieldLevel) bool {
address := fl.Field().String()
- return ethAddressRegex.MatchString(address)
+ return ethAddressRegex().MatchString(address)
}
// isEthereumAddressChecksum is the validation function for validating if the field's value is a valid checksummed Ethereum address.
func isEthereumAddressChecksum(fl FieldLevel) bool {
address := fl.Field().String()
- if !ethAddressRegex.MatchString(address) {
+ if !ethAddressRegex().MatchString(address) {
return false
}
// Checksum validation. Reference: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md
@@ -721,7 +721,7 @@ func isEthereumAddressChecksum(fl FieldLevel) bool {
func isBitcoinAddress(fl FieldLevel) bool {
address := fl.Field().String()
- if !btcAddressRegex.MatchString(address) {
+ if !btcAddressRegex().MatchString(address) {
return false
}
@@ -758,7 +758,7 @@ func isBitcoinAddress(fl FieldLevel) bool {
func isBitcoinBech32Address(fl FieldLevel) bool {
address := fl.Field().String()
- if !btcLowerAddressRegexBech32.MatchString(address) && !btcUpperAddressRegexBech32.MatchString(address) {
+ if !btcLowerAddressRegexBech32().MatchString(address) && !btcUpperAddressRegexBech32().MatchString(address) {
return false
}
@@ -1370,6 +1370,7 @@ func isPostcodeByIso3166Alpha2(fl FieldLevel) bool {
field := fl.Field()
param := fl.Param()
+ postcodeRegexInit.Do(initPostcodes)
reg, found := postCodeRegexDict[param]
if !found {
return false
@@ -1407,22 +1408,22 @@ func isPostcodeByIso3166Alpha2Field(fl FieldLevel) bool {
// isBase32 is the validation function for validating if the current field's value is a valid base 32.
func isBase32(fl FieldLevel) bool {
- return base32Regex.MatchString(fl.Field().String())
+ return base32Regex().MatchString(fl.Field().String())
}
// isBase64 is the validation function for validating if the current field's value is a valid base 64.
func isBase64(fl FieldLevel) bool {
- return base64Regex.MatchString(fl.Field().String())
+ return base64Regex().MatchString(fl.Field().String())
}
// isBase64URL is the validation function for validating if the current field's value is a valid base64 URL safe string.
func isBase64URL(fl FieldLevel) bool {
- return base64URLRegex.MatchString(fl.Field().String())
+ return base64URLRegex().MatchString(fl.Field().String())
}
// isBase64RawURL is the validation function for validating if the current field's value is a valid base64 URL safe string without '=' padding.
func isBase64RawURL(fl FieldLevel) bool {
- return base64RawURLRegex.MatchString(fl.Field().String())
+ return base64RawURLRegex().MatchString(fl.Field().String())
}
// isURI is the validation function for validating if the current field's value is a valid URI.
@@ -1668,42 +1669,42 @@ func isFilePath(fl FieldLevel) bool {
// isE164 is the validation function for validating if the current field's value is a valid e.164 formatted phone number.
func isE164(fl FieldLevel) bool {
- return e164Regex.MatchString(fl.Field().String())
+ return e164Regex().MatchString(fl.Field().String())
}
// isEmail is the validation function for validating if the current field's value is a valid email address.
func isEmail(fl FieldLevel) bool {
- return emailRegex.MatchString(fl.Field().String())
+ return emailRegex().MatchString(fl.Field().String())
}
// isHSLA is the validation function for validating if the current field's value is a valid HSLA color.
func isHSLA(fl FieldLevel) bool {
- return hslaRegex.MatchString(fl.Field().String())
+ return hslaRegex().MatchString(fl.Field().String())
}
// isHSL is the validation function for validating if the current field's value is a valid HSL color.
func isHSL(fl FieldLevel) bool {
- return hslRegex.MatchString(fl.Field().String())
+ return hslRegex().MatchString(fl.Field().String())
}
// isRGBA is the validation function for validating if the current field's value is a valid RGBA color.
func isRGBA(fl FieldLevel) bool {
- return rgbaRegex.MatchString(fl.Field().String())
+ return rgbaRegex().MatchString(fl.Field().String())
}
// isRGB is the validation function for validating if the current field's value is a valid RGB color.
func isRGB(fl FieldLevel) bool {
- return rgbRegex.MatchString(fl.Field().String())
+ return rgbRegex().MatchString(fl.Field().String())
}
// isHEXColor is the validation function for validating if the current field's value is a valid HEX color.
func isHEXColor(fl FieldLevel) bool {
- return hexColorRegex.MatchString(fl.Field().String())
+ return hexColorRegex().MatchString(fl.Field().String())
}
// isHexadecimal is the validation function for validating if the current field's value is a valid hexadecimal.
func isHexadecimal(fl FieldLevel) bool {
- return hexadecimalRegex.MatchString(fl.Field().String())
+ return hexadecimalRegex().MatchString(fl.Field().String())
}
// isNumber is the validation function for validating if the current field's value is a valid number.
@@ -1712,7 +1713,7 @@ func isNumber(fl FieldLevel) bool {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64:
return true
default:
- return numberRegex.MatchString(fl.Field().String())
+ return numberRegex().MatchString(fl.Field().String())
}
}
@@ -1722,28 +1723,28 @@ func isNumeric(fl FieldLevel) bool {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64:
return true
default:
- return numericRegex.MatchString(fl.Field().String())
+ return numericRegex().MatchString(fl.Field().String())
}
}
// isAlphanum is the validation function for validating if the current field's value is a valid alphanumeric value.
func isAlphanum(fl FieldLevel) bool {
- return alphaNumericRegex.MatchString(fl.Field().String())
+ return alphaNumericRegex().MatchString(fl.Field().String())
}
// isAlpha is the validation function for validating if the current field's value is a valid alpha value.
func isAlpha(fl FieldLevel) bool {
- return alphaRegex.MatchString(fl.Field().String())
+ return alphaRegex().MatchString(fl.Field().String())
}
// isAlphanumUnicode is the validation function for validating if the current field's value is a valid alphanumeric unicode value.
func isAlphanumUnicode(fl FieldLevel) bool {
- return alphaUnicodeNumericRegex.MatchString(fl.Field().String())
+ return alphaUnicodeNumericRegex().MatchString(fl.Field().String())
}
// isAlphaUnicode is the validation function for validating if the current field's value is a valid alpha unicode value.
func isAlphaUnicode(fl FieldLevel) bool {
- return alphaUnicodeRegex.MatchString(fl.Field().String())
+ return alphaUnicodeRegex().MatchString(fl.Field().String())
}
// isBoolean is the validation function for validating if the current field's value is a valid boolean value or can be safely converted to a boolean value.
@@ -2566,11 +2567,11 @@ func isIP6Addr(fl FieldLevel) bool {
}
func isHostnameRFC952(fl FieldLevel) bool {
- return hostnameRegexRFC952.MatchString(fl.Field().String())
+ return hostnameRegexRFC952().MatchString(fl.Field().String())
}
func isHostnameRFC1123(fl FieldLevel) bool {
- return hostnameRegexRFC1123.MatchString(fl.Field().String())
+ return hostnameRegexRFC1123().MatchString(fl.Field().String())
}
func isFQDN(fl FieldLevel) bool {
@@ -2580,7 +2581,7 @@ func isFQDN(fl FieldLevel) bool {
return false
}
- return fqdnRegexRFC1123.MatchString(val)
+ return fqdnRegexRFC1123().MatchString(val)
}
// isDir is the validation function for validating if the current field's value is a valid existing directory.
@@ -2679,7 +2680,7 @@ func isJSON(fl FieldLevel) bool {
// isJWT is the validation function for validating if the current field's value is a valid JWT string.
func isJWT(fl FieldLevel) bool {
- return jWTRegex.MatchString(fl.Field().String())
+ return jWTRegex().MatchString(fl.Field().String())
}
// isHostnamePort validates a >16&255,u[c++]=t>>8&255,u[c++]=255&t;2===s&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,u[c++]=255&t);1===s&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,u[c++]=t>>8&255,u[c++]=255&t);return u},t.fromByteArray=function(e){for(var t,n=e.length,o=n%3,a=[],i=16383,s=0,l=n-o;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,n){for(var o,a,i=[],s=t;ss&&(r=s-l),a=r;a>=0;a--){let r=!0;for(let n=0;n>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let a=!1;for(;;)switch(n){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return E(this,e,t,r);case"ascii":case"latin1":case"binary":return x(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const C=4096;function O(e,t,r){let n="";r=Math.min(e.length,r);for(let o=t;o