PageRenderTime 280ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/github.com/asaskevich/govalidator/patterns.go

https://gitlab.com/unofficial-mirrors/kubernetes
Go | 83 lines | 74 code | 4 blank | 5 comment | 0 complexity | 5f26f278b9160c9747fce68f942eb399 MD5 | raw file
  1. package govalidator
  2. import "regexp"
  3. // Basic regular expressions for validating strings
  4. const (
  5. Email string = "^(((([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}])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([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]|\\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}])))\\.?$"
  6. CreditCard string = "^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\\d{3})\\d{11})$"
  7. ISBN10 string = "^(?:[0-9]{9}X|[0-9]{10})$"
  8. ISBN13 string = "^(?:[0-9]{13})$"
  9. UUID3 string = "^[0-9a-f]{8}-[0-9a-f]{4}-3[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$"
  10. UUID4 string = "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
  11. UUID5 string = "^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
  12. UUID string = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
  13. Alpha string = "^[a-zA-Z]+$"
  14. Alphanumeric string = "^[a-zA-Z0-9]+$"
  15. Numeric string = "^[-+]?[0-9]+$"
  16. Int string = "^(?:[-+]?(?:0|[1-9][0-9]*))$"
  17. Float string = "^(?:[-+]?(?:[0-9]+))?(?:\\.[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$"
  18. Hexadecimal string = "^[0-9a-fA-F]+$"
  19. Hexcolor string = "^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"
  20. RGBcolor string = "^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])\\s*\\)$"
  21. ASCII string = "^[\x00-\x7F]+$"
  22. Multibyte string = "[^\x00-\x7F]"
  23. FullWidth string = "[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]"
  24. HalfWidth string = "[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]"
  25. Base64 string = "^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{4})$"
  26. PrintableASCII string = "^[\x20-\x7E]+$"
  27. DataURI string = "^data:.+\\/(.+);base64$"
  28. Latitude string = "^[-+]?([1-8]?\\d(\\.\\d+)?|90(\\.0+)?)$"
  29. Longitude string = "^[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"
  30. DNSName string = `^([a-zA-Z0-9]{1}[a-zA-Z0-9_-]{1,62}){1}(\.[a-zA-Z0-9]{1}[a-zA-Z0-9_-]{1,62})*$`
  31. URL string = `^((ftp|https?):\/\/)?(\S+(:\S*)?@)?((([1-9]\d?|1\d\d|2[01]\d|22[0-3])(\.(1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.([0-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(([a-zA-Z0-9]([a-zA-Z0-9-]+)?[a-zA-Z0-9]([-\.][a-zA-Z0-9]+)*)|((www\.)?))?(([a-zA-Z\x{00a1}-\x{ffff}0-9]+-?-?)*[a-zA-Z\x{00a1}-\x{ffff}0-9]+)(?:\.([a-zA-Z\x{00a1}-\x{ffff}]{1,}))?))(:(\d{1,5}))?((\/|\?|#)[^\s]*)?$`
  32. SSN string = `^\d{3}[- ]?\d{2}[- ]?\d{4}$`
  33. WinPath string = `^[a-zA-Z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$`
  34. UnixPath string = `^((?:\/[a-zA-Z0-9\.\:]+(?:_[a-zA-Z0-9\:\.]+)*(?:\-[\:a-zA-Z0-9\.]+)*)+\/?)$`
  35. Semver string = "^v?(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(-(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(\\.(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\\+[0-9a-zA-Z-]+(\\.[0-9a-zA-Z-]+)*)?$"
  36. tagName string = "valid"
  37. )
  38. // Used by IsFilePath func
  39. const (
  40. // Unknown is unresolved OS type
  41. Unknown = iota
  42. // Win is Windows type
  43. Win
  44. // Unix is *nix OS types
  45. Unix
  46. )
  47. var (
  48. rxEmail = regexp.MustCompile(Email)
  49. rxCreditCard = regexp.MustCompile(CreditCard)
  50. rxISBN10 = regexp.MustCompile(ISBN10)
  51. rxISBN13 = regexp.MustCompile(ISBN13)
  52. rxUUID3 = regexp.MustCompile(UUID3)
  53. rxUUID4 = regexp.MustCompile(UUID4)
  54. rxUUID5 = regexp.MustCompile(UUID5)
  55. rxUUID = regexp.MustCompile(UUID)
  56. rxAlpha = regexp.MustCompile(Alpha)
  57. rxAlphanumeric = regexp.MustCompile(Alphanumeric)
  58. rxNumeric = regexp.MustCompile(Numeric)
  59. rxInt = regexp.MustCompile(Int)
  60. rxFloat = regexp.MustCompile(Float)
  61. rxHexadecimal = regexp.MustCompile(Hexadecimal)
  62. rxHexcolor = regexp.MustCompile(Hexcolor)
  63. rxRGBcolor = regexp.MustCompile(RGBcolor)
  64. rxASCII = regexp.MustCompile(ASCII)
  65. rxPrintableASCII = regexp.MustCompile(PrintableASCII)
  66. rxMultibyte = regexp.MustCompile(Multibyte)
  67. rxFullWidth = regexp.MustCompile(FullWidth)
  68. rxHalfWidth = regexp.MustCompile(HalfWidth)
  69. rxBase64 = regexp.MustCompile(Base64)
  70. rxDataURI = regexp.MustCompile(DataURI)
  71. rxLatitude = regexp.MustCompile(Latitude)
  72. rxLongitude = regexp.MustCompile(Longitude)
  73. rxDNSName = regexp.MustCompile(DNSName)
  74. rxURL = regexp.MustCompile(URL)
  75. rxSSN = regexp.MustCompile(SSN)
  76. rxWinPath = regexp.MustCompile(WinPath)
  77. rxUnixPath = regexp.MustCompile(UnixPath)
  78. rxSemver = regexp.MustCompile(Semver)
  79. )