/envoy/config/common/matcher/v3/matcher.pb.validate.go

https://github.com/envoyproxy/go-control-plane · Go · 585 lines · 412 code · 112 blank · 61 comment · 72 complexity · df224928abce7233bd6457662bdfc09c MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/config/common/matcher/v3/matcher.proto
  3. package envoy_config_common_matcher_v3
  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 _matcher_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 MatchPredicate 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 *MatchPredicate) Validate() error {
  37. if m == nil {
  38. return nil
  39. }
  40. switch m.Rule.(type) {
  41. case *MatchPredicate_OrMatch:
  42. if v, ok := interface{}(m.GetOrMatch()).(interface{ Validate() error }); ok {
  43. if err := v.Validate(); err != nil {
  44. return MatchPredicateValidationError{
  45. field: "OrMatch",
  46. reason: "embedded message failed validation",
  47. cause: err,
  48. }
  49. }
  50. }
  51. case *MatchPredicate_AndMatch:
  52. if v, ok := interface{}(m.GetAndMatch()).(interface{ Validate() error }); ok {
  53. if err := v.Validate(); err != nil {
  54. return MatchPredicateValidationError{
  55. field: "AndMatch",
  56. reason: "embedded message failed validation",
  57. cause: err,
  58. }
  59. }
  60. }
  61. case *MatchPredicate_NotMatch:
  62. if v, ok := interface{}(m.GetNotMatch()).(interface{ Validate() error }); ok {
  63. if err := v.Validate(); err != nil {
  64. return MatchPredicateValidationError{
  65. field: "NotMatch",
  66. reason: "embedded message failed validation",
  67. cause: err,
  68. }
  69. }
  70. }
  71. case *MatchPredicate_AnyMatch:
  72. if m.GetAnyMatch() != true {
  73. return MatchPredicateValidationError{
  74. field: "AnyMatch",
  75. reason: "value must equal true",
  76. }
  77. }
  78. case *MatchPredicate_HttpRequestHeadersMatch:
  79. if v, ok := interface{}(m.GetHttpRequestHeadersMatch()).(interface{ Validate() error }); ok {
  80. if err := v.Validate(); err != nil {
  81. return MatchPredicateValidationError{
  82. field: "HttpRequestHeadersMatch",
  83. reason: "embedded message failed validation",
  84. cause: err,
  85. }
  86. }
  87. }
  88. case *MatchPredicate_HttpRequestTrailersMatch:
  89. if v, ok := interface{}(m.GetHttpRequestTrailersMatch()).(interface{ Validate() error }); ok {
  90. if err := v.Validate(); err != nil {
  91. return MatchPredicateValidationError{
  92. field: "HttpRequestTrailersMatch",
  93. reason: "embedded message failed validation",
  94. cause: err,
  95. }
  96. }
  97. }
  98. case *MatchPredicate_HttpResponseHeadersMatch:
  99. if v, ok := interface{}(m.GetHttpResponseHeadersMatch()).(interface{ Validate() error }); ok {
  100. if err := v.Validate(); err != nil {
  101. return MatchPredicateValidationError{
  102. field: "HttpResponseHeadersMatch",
  103. reason: "embedded message failed validation",
  104. cause: err,
  105. }
  106. }
  107. }
  108. case *MatchPredicate_HttpResponseTrailersMatch:
  109. if v, ok := interface{}(m.GetHttpResponseTrailersMatch()).(interface{ Validate() error }); ok {
  110. if err := v.Validate(); err != nil {
  111. return MatchPredicateValidationError{
  112. field: "HttpResponseTrailersMatch",
  113. reason: "embedded message failed validation",
  114. cause: err,
  115. }
  116. }
  117. }
  118. case *MatchPredicate_HttpRequestGenericBodyMatch:
  119. if v, ok := interface{}(m.GetHttpRequestGenericBodyMatch()).(interface{ Validate() error }); ok {
  120. if err := v.Validate(); err != nil {
  121. return MatchPredicateValidationError{
  122. field: "HttpRequestGenericBodyMatch",
  123. reason: "embedded message failed validation",
  124. cause: err,
  125. }
  126. }
  127. }
  128. case *MatchPredicate_HttpResponseGenericBodyMatch:
  129. if v, ok := interface{}(m.GetHttpResponseGenericBodyMatch()).(interface{ Validate() error }); ok {
  130. if err := v.Validate(); err != nil {
  131. return MatchPredicateValidationError{
  132. field: "HttpResponseGenericBodyMatch",
  133. reason: "embedded message failed validation",
  134. cause: err,
  135. }
  136. }
  137. }
  138. default:
  139. return MatchPredicateValidationError{
  140. field: "Rule",
  141. reason: "value is required",
  142. }
  143. }
  144. return nil
  145. }
  146. // MatchPredicateValidationError is the validation error returned by
  147. // MatchPredicate.Validate if the designated constraints aren't met.
  148. type MatchPredicateValidationError struct {
  149. field string
  150. reason string
  151. cause error
  152. key bool
  153. }
  154. // Field function returns field value.
  155. func (e MatchPredicateValidationError) Field() string { return e.field }
  156. // Reason function returns reason value.
  157. func (e MatchPredicateValidationError) Reason() string { return e.reason }
  158. // Cause function returns cause value.
  159. func (e MatchPredicateValidationError) Cause() error { return e.cause }
  160. // Key function returns key value.
  161. func (e MatchPredicateValidationError) Key() bool { return e.key }
  162. // ErrorName returns error name.
  163. func (e MatchPredicateValidationError) ErrorName() string { return "MatchPredicateValidationError" }
  164. // Error satisfies the builtin error interface
  165. func (e MatchPredicateValidationError) Error() string {
  166. cause := ""
  167. if e.cause != nil {
  168. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  169. }
  170. key := ""
  171. if e.key {
  172. key = "key for "
  173. }
  174. return fmt.Sprintf(
  175. "invalid %sMatchPredicate.%s: %s%s",
  176. key,
  177. e.field,
  178. e.reason,
  179. cause)
  180. }
  181. var _ error = MatchPredicateValidationError{}
  182. var _ interface {
  183. Field() string
  184. Reason() string
  185. Key() bool
  186. Cause() error
  187. ErrorName() string
  188. } = MatchPredicateValidationError{}
  189. // Validate checks the field values on HttpHeadersMatch with the rules defined
  190. // in the proto definition for this message. If any rules are violated, an
  191. // error is returned.
  192. func (m *HttpHeadersMatch) Validate() error {
  193. if m == nil {
  194. return nil
  195. }
  196. for idx, item := range m.GetHeaders() {
  197. _, _ = idx, item
  198. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  199. if err := v.Validate(); err != nil {
  200. return HttpHeadersMatchValidationError{
  201. field: fmt.Sprintf("Headers[%v]", idx),
  202. reason: "embedded message failed validation",
  203. cause: err,
  204. }
  205. }
  206. }
  207. }
  208. return nil
  209. }
  210. // HttpHeadersMatchValidationError is the validation error returned by
  211. // HttpHeadersMatch.Validate if the designated constraints aren't met.
  212. type HttpHeadersMatchValidationError struct {
  213. field string
  214. reason string
  215. cause error
  216. key bool
  217. }
  218. // Field function returns field value.
  219. func (e HttpHeadersMatchValidationError) Field() string { return e.field }
  220. // Reason function returns reason value.
  221. func (e HttpHeadersMatchValidationError) Reason() string { return e.reason }
  222. // Cause function returns cause value.
  223. func (e HttpHeadersMatchValidationError) Cause() error { return e.cause }
  224. // Key function returns key value.
  225. func (e HttpHeadersMatchValidationError) Key() bool { return e.key }
  226. // ErrorName returns error name.
  227. func (e HttpHeadersMatchValidationError) ErrorName() string { return "HttpHeadersMatchValidationError" }
  228. // Error satisfies the builtin error interface
  229. func (e HttpHeadersMatchValidationError) Error() string {
  230. cause := ""
  231. if e.cause != nil {
  232. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  233. }
  234. key := ""
  235. if e.key {
  236. key = "key for "
  237. }
  238. return fmt.Sprintf(
  239. "invalid %sHttpHeadersMatch.%s: %s%s",
  240. key,
  241. e.field,
  242. e.reason,
  243. cause)
  244. }
  245. var _ error = HttpHeadersMatchValidationError{}
  246. var _ interface {
  247. Field() string
  248. Reason() string
  249. Key() bool
  250. Cause() error
  251. ErrorName() string
  252. } = HttpHeadersMatchValidationError{}
  253. // Validate checks the field values on HttpGenericBodyMatch with the rules
  254. // defined in the proto definition for this message. If any rules are
  255. // violated, an error is returned.
  256. func (m *HttpGenericBodyMatch) Validate() error {
  257. if m == nil {
  258. return nil
  259. }
  260. // no validation rules for BytesLimit
  261. if len(m.GetPatterns()) < 1 {
  262. return HttpGenericBodyMatchValidationError{
  263. field: "Patterns",
  264. reason: "value must contain at least 1 item(s)",
  265. }
  266. }
  267. for idx, item := range m.GetPatterns() {
  268. _, _ = idx, item
  269. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  270. if err := v.Validate(); err != nil {
  271. return HttpGenericBodyMatchValidationError{
  272. field: fmt.Sprintf("Patterns[%v]", idx),
  273. reason: "embedded message failed validation",
  274. cause: err,
  275. }
  276. }
  277. }
  278. }
  279. return nil
  280. }
  281. // HttpGenericBodyMatchValidationError is the validation error returned by
  282. // HttpGenericBodyMatch.Validate if the designated constraints aren't met.
  283. type HttpGenericBodyMatchValidationError struct {
  284. field string
  285. reason string
  286. cause error
  287. key bool
  288. }
  289. // Field function returns field value.
  290. func (e HttpGenericBodyMatchValidationError) Field() string { return e.field }
  291. // Reason function returns reason value.
  292. func (e HttpGenericBodyMatchValidationError) Reason() string { return e.reason }
  293. // Cause function returns cause value.
  294. func (e HttpGenericBodyMatchValidationError) Cause() error { return e.cause }
  295. // Key function returns key value.
  296. func (e HttpGenericBodyMatchValidationError) Key() bool { return e.key }
  297. // ErrorName returns error name.
  298. func (e HttpGenericBodyMatchValidationError) ErrorName() string {
  299. return "HttpGenericBodyMatchValidationError"
  300. }
  301. // Error satisfies the builtin error interface
  302. func (e HttpGenericBodyMatchValidationError) Error() string {
  303. cause := ""
  304. if e.cause != nil {
  305. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  306. }
  307. key := ""
  308. if e.key {
  309. key = "key for "
  310. }
  311. return fmt.Sprintf(
  312. "invalid %sHttpGenericBodyMatch.%s: %s%s",
  313. key,
  314. e.field,
  315. e.reason,
  316. cause)
  317. }
  318. var _ error = HttpGenericBodyMatchValidationError{}
  319. var _ interface {
  320. Field() string
  321. Reason() string
  322. Key() bool
  323. Cause() error
  324. ErrorName() string
  325. } = HttpGenericBodyMatchValidationError{}
  326. // Validate checks the field values on MatchPredicate_MatchSet with the rules
  327. // defined in the proto definition for this message. If any rules are
  328. // violated, an error is returned.
  329. func (m *MatchPredicate_MatchSet) Validate() error {
  330. if m == nil {
  331. return nil
  332. }
  333. if len(m.GetRules()) < 2 {
  334. return MatchPredicate_MatchSetValidationError{
  335. field: "Rules",
  336. reason: "value must contain at least 2 item(s)",
  337. }
  338. }
  339. for idx, item := range m.GetRules() {
  340. _, _ = idx, item
  341. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  342. if err := v.Validate(); err != nil {
  343. return MatchPredicate_MatchSetValidationError{
  344. field: fmt.Sprintf("Rules[%v]", idx),
  345. reason: "embedded message failed validation",
  346. cause: err,
  347. }
  348. }
  349. }
  350. }
  351. return nil
  352. }
  353. // MatchPredicate_MatchSetValidationError is the validation error returned by
  354. // MatchPredicate_MatchSet.Validate if the designated constraints aren't met.
  355. type MatchPredicate_MatchSetValidationError struct {
  356. field string
  357. reason string
  358. cause error
  359. key bool
  360. }
  361. // Field function returns field value.
  362. func (e MatchPredicate_MatchSetValidationError) Field() string { return e.field }
  363. // Reason function returns reason value.
  364. func (e MatchPredicate_MatchSetValidationError) Reason() string { return e.reason }
  365. // Cause function returns cause value.
  366. func (e MatchPredicate_MatchSetValidationError) Cause() error { return e.cause }
  367. // Key function returns key value.
  368. func (e MatchPredicate_MatchSetValidationError) Key() bool { return e.key }
  369. // ErrorName returns error name.
  370. func (e MatchPredicate_MatchSetValidationError) ErrorName() string {
  371. return "MatchPredicate_MatchSetValidationError"
  372. }
  373. // Error satisfies the builtin error interface
  374. func (e MatchPredicate_MatchSetValidationError) Error() string {
  375. cause := ""
  376. if e.cause != nil {
  377. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  378. }
  379. key := ""
  380. if e.key {
  381. key = "key for "
  382. }
  383. return fmt.Sprintf(
  384. "invalid %sMatchPredicate_MatchSet.%s: %s%s",
  385. key,
  386. e.field,
  387. e.reason,
  388. cause)
  389. }
  390. var _ error = MatchPredicate_MatchSetValidationError{}
  391. var _ interface {
  392. Field() string
  393. Reason() string
  394. Key() bool
  395. Cause() error
  396. ErrorName() string
  397. } = MatchPredicate_MatchSetValidationError{}
  398. // Validate checks the field values on HttpGenericBodyMatch_GenericTextMatch
  399. // with the rules defined in the proto definition for this message. If any
  400. // rules are violated, an error is returned.
  401. func (m *HttpGenericBodyMatch_GenericTextMatch) Validate() error {
  402. if m == nil {
  403. return nil
  404. }
  405. switch m.Rule.(type) {
  406. case *HttpGenericBodyMatch_GenericTextMatch_StringMatch:
  407. if utf8.RuneCountInString(m.GetStringMatch()) < 1 {
  408. return HttpGenericBodyMatch_GenericTextMatchValidationError{
  409. field: "StringMatch",
  410. reason: "value length must be at least 1 runes",
  411. }
  412. }
  413. case *HttpGenericBodyMatch_GenericTextMatch_BinaryMatch:
  414. if len(m.GetBinaryMatch()) < 1 {
  415. return HttpGenericBodyMatch_GenericTextMatchValidationError{
  416. field: "BinaryMatch",
  417. reason: "value length must be at least 1 bytes",
  418. }
  419. }
  420. default:
  421. return HttpGenericBodyMatch_GenericTextMatchValidationError{
  422. field: "Rule",
  423. reason: "value is required",
  424. }
  425. }
  426. return nil
  427. }
  428. // HttpGenericBodyMatch_GenericTextMatchValidationError is the validation error
  429. // returned by HttpGenericBodyMatch_GenericTextMatch.Validate if the
  430. // designated constraints aren't met.
  431. type HttpGenericBodyMatch_GenericTextMatchValidationError struct {
  432. field string
  433. reason string
  434. cause error
  435. key bool
  436. }
  437. // Field function returns field value.
  438. func (e HttpGenericBodyMatch_GenericTextMatchValidationError) Field() string { return e.field }
  439. // Reason function returns reason value.
  440. func (e HttpGenericBodyMatch_GenericTextMatchValidationError) Reason() string { return e.reason }
  441. // Cause function returns cause value.
  442. func (e HttpGenericBodyMatch_GenericTextMatchValidationError) Cause() error { return e.cause }
  443. // Key function returns key value.
  444. func (e HttpGenericBodyMatch_GenericTextMatchValidationError) Key() bool { return e.key }
  445. // ErrorName returns error name.
  446. func (e HttpGenericBodyMatch_GenericTextMatchValidationError) ErrorName() string {
  447. return "HttpGenericBodyMatch_GenericTextMatchValidationError"
  448. }
  449. // Error satisfies the builtin error interface
  450. func (e HttpGenericBodyMatch_GenericTextMatchValidationError) Error() string {
  451. cause := ""
  452. if e.cause != nil {
  453. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  454. }
  455. key := ""
  456. if e.key {
  457. key = "key for "
  458. }
  459. return fmt.Sprintf(
  460. "invalid %sHttpGenericBodyMatch_GenericTextMatch.%s: %s%s",
  461. key,
  462. e.field,
  463. e.reason,
  464. cause)
  465. }
  466. var _ error = HttpGenericBodyMatch_GenericTextMatchValidationError{}
  467. var _ interface {
  468. Field() string
  469. Reason() string
  470. Key() bool
  471. Cause() error
  472. ErrorName() string
  473. } = HttpGenericBodyMatch_GenericTextMatchValidationError{}