PageRenderTime 21ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/ssi/vendor/github.com/go-playground/validator/regexes.go

https://gitlab.com/nidhomriza/handbook-tes
Go | 97 lines | 94 code | 3 blank | 0 comment | 0 complexity | 50dc25d3352a5b9982b7969fbd2044b0 MD5 | raw file
  1. package validator
  2. import "regexp"
  3. const (
  4. alphaRegexString = "^[a-zA-Z]+$"
  5. alphaNumericRegexString = "^[a-zA-Z0-9]+$"
  6. alphaUnicodeRegexString = "^[\\p{L}]+$"
  7. alphaUnicodeNumericRegexString = "^[\\p{L}\\p{N}]+$"
  8. numericRegexString = "^[-+]?[0-9]+(?:\\.[0-9]+)?$"
  9. numberRegexString = "^[0-9]+$"
  10. hexadecimalRegexString = "^[0-9a-fA-F]+$"
  11. hexcolorRegexString = "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"
  12. rgbRegexString = "^rgb\\(\\s*(?:(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])|(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])%\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])%\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])%)\\s*\\)$"
  13. rgbaRegexString = "^rgba\\(\\s*(?:(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])|(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])%\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|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0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(?:(?:[a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])(?:[a-zA-Z]|\\d|-|\\.|~|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])*(?:[a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.)+(?:(?:[a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(?:(?:[a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])(?:[a-zA-Z]|\\d|-|\\.|~|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])*(?:[a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.?$"
  17. e164RegexString = "^\\+[1-9]?[0-9]{7,14}$"
  18. base64RegexString = "^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{4})$"
  19. base64URLRegexString = "^(?:[A-Za-z0-9-_]{4})*(?:[A-Za-z0-9-_]{2}==|[A-Za-z0-9-_]{3}=|[A-Za-z0-9-_]{4})$"
  20. iSBN10RegexString = "^(?:[0-9]{9}X|[0-9]{10})$"
  21. iSBN13RegexString = "^(?:(?:97(?:8|9))[0-9]{10})$"
  22. uUID3RegexString = "^[0-9a-f]{8}-[0-9a-f]{4}-3[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$"
  23. uUID4RegexString = "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
  24. uUID5RegexString = "^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
  25. uUIDRegexString = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
  26. uUID3RFC4122RegexString = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-3[0-9a-fA-F]{3}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
  27. uUID4RFC4122RegexString = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
  28. uUID5RFC4122RegexString = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-5[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
  29. uUIDRFC4122RegexString = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
  30. aSCIIRegexString = "^[\x00-\x7F]*$"
  31. printableASCIIRegexString = "^[\x20-\x7E]*$"
  32. multibyteRegexString = "[^\x00-\x7F]"
  33. dataURIRegexString = "^data:.+\\/(.+);base64$"
  34. latitudeRegexString = "^[-+]?([1-8]?\\d(\\.\\d+)?|90(\\.0+)?)$"
  35. longitudeRegexString = "^[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"
  36. sSNRegexString = `^[0-9]{3}[ -]?(0[1-9]|[1-9][0-9])[ -]?([1-9][0-9]{3}|[0-9][1-9][0-9]{2}|[0-9]{2}[1-9][0-9]|[0-9]{3}[1-9])$`
  37. hostnameRegexStringRFC952 = `^[a-zA-Z][a-zA-Z0-9\-\.]+[a-zA-Z0-9]$` // https://tools.ietf.org/html/rfc952
  38. hostnameRegexStringRFC1123 = `^[a-zA-Z0-9][a-zA-Z0-9\-\.]+[a-zA-Z0-9]$` // accepts hostname starting with a digit https://tools.ietf.org/html/rfc1123
  39. btcAddressRegexString = `^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$` // bitcoin address
  40. btcAddressUpperRegexStringBech32 = `^BC1[02-9AC-HJ-NP-Z]{7,76}$` // bitcoin bech32 address https://en.bitcoin.it/wiki/Bech32
  41. btcAddressLowerRegexStringBech32 = `^bc1[02-9ac-hj-np-z]{7,76}$` // bitcoin bech32 address https://en.bitcoin.it/wiki/Bech32
  42. ethAddressRegexString = `^0x[0-9a-fA-F]{40}$`
  43. ethAddressUpperRegexString = `^0x[0-9A-F]{40}$`
  44. ethAddressLowerRegexString = `^0x[0-9a-f]{40}$`
  45. uRLEncodedRegexString = `(%[A-Fa-f0-9]{2})`
  46. hTMLEncodedRegexString = `&#[x]?([0-9a-fA-F]{2})|(&gt)|(&lt)|(&quot)|(&amp)+[;]?`
  47. hTMLRegexString = `<[/]?([a-zA-Z]+).*?>`
  48. )
  49. var (
  50. alphaRegex = regexp.MustCompile(alphaRegexString)
  51. alphaNumericRegex = regexp.MustCompile(alphaNumericRegexString)
  52. alphaUnicodeRegex = regexp.MustCompile(alphaUnicodeRegexString)
  53. alphaUnicodeNumericRegex = regexp.MustCompile(alphaUnicodeNumericRegexString)
  54. numericRegex = regexp.MustCompile(numericRegexString)
  55. numberRegex = regexp.MustCompile(numberRegexString)
  56. hexadecimalRegex = regexp.MustCompile(hexadecimalRegexString)
  57. hexcolorRegex = regexp.MustCompile(hexcolorRegexString)
  58. rgbRegex = regexp.MustCompile(rgbRegexString)
  59. rgbaRegex = regexp.MustCompile(rgbaRegexString)
  60. hslRegex = regexp.MustCompile(hslRegexString)
  61. hslaRegex = regexp.MustCompile(hslaRegexString)
  62. e164Regex = regexp.MustCompile(e164RegexString)
  63. emailRegex = regexp.MustCompile(emailRegexString)
  64. base64Regex = regexp.MustCompile(base64RegexString)
  65. base64URLRegex = regexp.MustCompile(base64URLRegexString)
  66. iSBN10Regex = regexp.MustCompile(iSBN10RegexString)
  67. iSBN13Regex = regexp.MustCompile(iSBN13RegexString)
  68. uUID3Regex = regexp.MustCompile(uUID3RegexString)
  69. uUID4Regex = regexp.MustCompile(uUID4RegexString)
  70. uUID5Regex = regexp.MustCompile(uUID5RegexString)
  71. uUIDRegex = regexp.MustCompile(uUIDRegexString)
  72. uUID3RFC4122Regex = regexp.MustCompile(uUID3RFC4122RegexString)
  73. uUID4RFC4122Regex = regexp.MustCompile(uUID4RFC4122RegexString)
  74. uUID5RFC4122Regex = regexp.MustCompile(uUID5RFC4122RegexString)
  75. uUIDRFC4122Regex = regexp.MustCompile(uUIDRFC4122RegexString)
  76. aSCIIRegex = regexp.MustCompile(aSCIIRegexString)
  77. printableASCIIRegex = regexp.MustCompile(printableASCIIRegexString)
  78. multibyteRegex = regexp.MustCompile(multibyteRegexString)
  79. dataURIRegex = regexp.MustCompile(dataURIRegexString)
  80. latitudeRegex = regexp.MustCompile(latitudeRegexString)
  81. longitudeRegex = regexp.MustCompile(longitudeRegexString)
  82. sSNRegex = regexp.MustCompile(sSNRegexString)
  83. hostnameRegexRFC952 = regexp.MustCompile(hostnameRegexStringRFC952)
  84. hostnameRegexRFC1123 = regexp.MustCompile(hostnameRegexStringRFC1123)
  85. btcAddressRegex = regexp.MustCompile(btcAddressRegexString)
  86. btcUpperAddressRegexBech32 = regexp.MustCompile(btcAddressUpperRegexStringBech32)
  87. btcLowerAddressRegexBech32 = regexp.MustCompile(btcAddressLowerRegexStringBech32)
  88. ethAddressRegex = regexp.MustCompile(ethAddressRegexString)
  89. ethaddressRegexUpper = regexp.MustCompile(ethAddressUpperRegexString)
  90. ethAddressRegexLower = regexp.MustCompile(ethAddressLowerRegexString)
  91. uRLEncodedRegex = regexp.MustCompile(uRLEncodedRegexString)
  92. hTMLEncodedRegex = regexp.MustCompile(hTMLEncodedRegexString)
  93. hTMLRegex = regexp.MustCompile(hTMLRegexString)
  94. )