/envoy/type/matcher/regex.pb.validate.go

https://github.com/envoyproxy/go-control-plane · Go · 294 lines · 202 code · 54 blank · 38 comment · 28 complexity · 9c23d903e94632f1ef5bafb9f1b64d1e MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/type/matcher/regex.proto
  3. package envoy_type_matcher
  4. import (
  5. "bytes"
  6. "errors"
  7. "fmt"
  8. "net"
  9. "net/mail"
  10. "net/url"
  11. "regexp"
  12. "strings"
  13. "time"
  14. "unicode/utf8"
  15. "github.com/golang/protobuf/ptypes"
  16. )
  17. // ensure the imports are used
  18. var (
  19. _ = bytes.MinRead
  20. _ = errors.New("")
  21. _ = fmt.Print
  22. _ = utf8.UTFMax
  23. _ = (*regexp.Regexp)(nil)
  24. _ = (*strings.Reader)(nil)
  25. _ = net.IPv4len
  26. _ = time.Duration(0)
  27. _ = (*url.URL)(nil)
  28. _ = (*mail.Address)(nil)
  29. _ = ptypes.DynamicAny{}
  30. )
  31. // define the regex for a UUID once up-front
  32. var _regex_uuidPattern = regexp.MustCompile("^[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}$")
  33. // Validate checks the field values on RegexMatcher with the rules defined in
  34. // the proto definition for this message. If any rules are violated, an error
  35. // is returned.
  36. func (m *RegexMatcher) Validate() error {
  37. if m == nil {
  38. return nil
  39. }
  40. if utf8.RuneCountInString(m.GetRegex()) < 1 {
  41. return RegexMatcherValidationError{
  42. field: "Regex",
  43. reason: "value length must be at least 1 runes",
  44. }
  45. }
  46. switch m.EngineType.(type) {
  47. case *RegexMatcher_GoogleRe2:
  48. if m.GetGoogleRe2() == nil {
  49. return RegexMatcherValidationError{
  50. field: "GoogleRe2",
  51. reason: "value is required",
  52. }
  53. }
  54. if v, ok := interface{}(m.GetGoogleRe2()).(interface{ Validate() error }); ok {
  55. if err := v.Validate(); err != nil {
  56. return RegexMatcherValidationError{
  57. field: "GoogleRe2",
  58. reason: "embedded message failed validation",
  59. cause: err,
  60. }
  61. }
  62. }
  63. default:
  64. return RegexMatcherValidationError{
  65. field: "EngineType",
  66. reason: "value is required",
  67. }
  68. }
  69. return nil
  70. }
  71. // RegexMatcherValidationError is the validation error returned by
  72. // RegexMatcher.Validate if the designated constraints aren't met.
  73. type RegexMatcherValidationError struct {
  74. field string
  75. reason string
  76. cause error
  77. key bool
  78. }
  79. // Field function returns field value.
  80. func (e RegexMatcherValidationError) Field() string { return e.field }
  81. // Reason function returns reason value.
  82. func (e RegexMatcherValidationError) Reason() string { return e.reason }
  83. // Cause function returns cause value.
  84. func (e RegexMatcherValidationError) Cause() error { return e.cause }
  85. // Key function returns key value.
  86. func (e RegexMatcherValidationError) Key() bool { return e.key }
  87. // ErrorName returns error name.
  88. func (e RegexMatcherValidationError) ErrorName() string { return "RegexMatcherValidationError" }
  89. // Error satisfies the builtin error interface
  90. func (e RegexMatcherValidationError) Error() string {
  91. cause := ""
  92. if e.cause != nil {
  93. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  94. }
  95. key := ""
  96. if e.key {
  97. key = "key for "
  98. }
  99. return fmt.Sprintf(
  100. "invalid %sRegexMatcher.%s: %s%s",
  101. key,
  102. e.field,
  103. e.reason,
  104. cause)
  105. }
  106. var _ error = RegexMatcherValidationError{}
  107. var _ interface {
  108. Field() string
  109. Reason() string
  110. Key() bool
  111. Cause() error
  112. ErrorName() string
  113. } = RegexMatcherValidationError{}
  114. // Validate checks the field values on RegexMatchAndSubstitute with the rules
  115. // defined in the proto definition for this message. If any rules are
  116. // violated, an error is returned.
  117. func (m *RegexMatchAndSubstitute) Validate() error {
  118. if m == nil {
  119. return nil
  120. }
  121. if v, ok := interface{}(m.GetPattern()).(interface{ Validate() error }); ok {
  122. if err := v.Validate(); err != nil {
  123. return RegexMatchAndSubstituteValidationError{
  124. field: "Pattern",
  125. reason: "embedded message failed validation",
  126. cause: err,
  127. }
  128. }
  129. }
  130. // no validation rules for Substitution
  131. return nil
  132. }
  133. // RegexMatchAndSubstituteValidationError is the validation error returned by
  134. // RegexMatchAndSubstitute.Validate if the designated constraints aren't met.
  135. type RegexMatchAndSubstituteValidationError struct {
  136. field string
  137. reason string
  138. cause error
  139. key bool
  140. }
  141. // Field function returns field value.
  142. func (e RegexMatchAndSubstituteValidationError) Field() string { return e.field }
  143. // Reason function returns reason value.
  144. func (e RegexMatchAndSubstituteValidationError) Reason() string { return e.reason }
  145. // Cause function returns cause value.
  146. func (e RegexMatchAndSubstituteValidationError) Cause() error { return e.cause }
  147. // Key function returns key value.
  148. func (e RegexMatchAndSubstituteValidationError) Key() bool { return e.key }
  149. // ErrorName returns error name.
  150. func (e RegexMatchAndSubstituteValidationError) ErrorName() string {
  151. return "RegexMatchAndSubstituteValidationError"
  152. }
  153. // Error satisfies the builtin error interface
  154. func (e RegexMatchAndSubstituteValidationError) Error() string {
  155. cause := ""
  156. if e.cause != nil {
  157. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  158. }
  159. key := ""
  160. if e.key {
  161. key = "key for "
  162. }
  163. return fmt.Sprintf(
  164. "invalid %sRegexMatchAndSubstitute.%s: %s%s",
  165. key,
  166. e.field,
  167. e.reason,
  168. cause)
  169. }
  170. var _ error = RegexMatchAndSubstituteValidationError{}
  171. var _ interface {
  172. Field() string
  173. Reason() string
  174. Key() bool
  175. Cause() error
  176. ErrorName() string
  177. } = RegexMatchAndSubstituteValidationError{}
  178. // Validate checks the field values on RegexMatcher_GoogleRE2 with the rules
  179. // defined in the proto definition for this message. If any rules are
  180. // violated, an error is returned.
  181. func (m *RegexMatcher_GoogleRE2) Validate() error {
  182. if m == nil {
  183. return nil
  184. }
  185. if v, ok := interface{}(m.GetMaxProgramSize()).(interface{ Validate() error }); ok {
  186. if err := v.Validate(); err != nil {
  187. return RegexMatcher_GoogleRE2ValidationError{
  188. field: "MaxProgramSize",
  189. reason: "embedded message failed validation",
  190. cause: err,
  191. }
  192. }
  193. }
  194. return nil
  195. }
  196. // RegexMatcher_GoogleRE2ValidationError is the validation error returned by
  197. // RegexMatcher_GoogleRE2.Validate if the designated constraints aren't met.
  198. type RegexMatcher_GoogleRE2ValidationError struct {
  199. field string
  200. reason string
  201. cause error
  202. key bool
  203. }
  204. // Field function returns field value.
  205. func (e RegexMatcher_GoogleRE2ValidationError) Field() string { return e.field }
  206. // Reason function returns reason value.
  207. func (e RegexMatcher_GoogleRE2ValidationError) Reason() string { return e.reason }
  208. // Cause function returns cause value.
  209. func (e RegexMatcher_GoogleRE2ValidationError) Cause() error { return e.cause }
  210. // Key function returns key value.
  211. func (e RegexMatcher_GoogleRE2ValidationError) Key() bool { return e.key }
  212. // ErrorName returns error name.
  213. func (e RegexMatcher_GoogleRE2ValidationError) ErrorName() string {
  214. return "RegexMatcher_GoogleRE2ValidationError"
  215. }
  216. // Error satisfies the builtin error interface
  217. func (e RegexMatcher_GoogleRE2ValidationError) Error() string {
  218. cause := ""
  219. if e.cause != nil {
  220. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  221. }
  222. key := ""
  223. if e.key {
  224. key = "key for "
  225. }
  226. return fmt.Sprintf(
  227. "invalid %sRegexMatcher_GoogleRE2.%s: %s%s",
  228. key,
  229. e.field,
  230. e.reason,
  231. cause)
  232. }
  233. var _ error = RegexMatcher_GoogleRE2ValidationError{}
  234. var _ interface {
  235. Field() string
  236. Reason() string
  237. Key() bool
  238. Cause() error
  239. ErrorName() string
  240. } = RegexMatcher_GoogleRE2ValidationError{}