/vendor/github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3/value.pb.validate.go

https://github.com/cloudfoundry/bosh-cli · Go · 522 lines · 380 code · 79 blank · 63 comment · 75 complexity · 1d203fb0c7fa56ab73f07a84725032c7 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/type/matcher/v3/value.proto
  3. package envoy_type_matcher_v3
  4. import (
  5. "bytes"
  6. "errors"
  7. "fmt"
  8. "net"
  9. "net/mail"
  10. "net/url"
  11. "regexp"
  12. "sort"
  13. "strings"
  14. "time"
  15. "unicode/utf8"
  16. "google.golang.org/protobuf/types/known/anypb"
  17. )
  18. // ensure the imports are used
  19. var (
  20. _ = bytes.MinRead
  21. _ = errors.New("")
  22. _ = fmt.Print
  23. _ = utf8.UTFMax
  24. _ = (*regexp.Regexp)(nil)
  25. _ = (*strings.Reader)(nil)
  26. _ = net.IPv4len
  27. _ = time.Duration(0)
  28. _ = (*url.URL)(nil)
  29. _ = (*mail.Address)(nil)
  30. _ = anypb.Any{}
  31. _ = sort.Sort
  32. )
  33. // Validate checks the field values on ValueMatcher with the rules defined in
  34. // the proto definition for this message. If any rules are violated, the first
  35. // error encountered is returned, or nil if there are no violations.
  36. func (m *ValueMatcher) Validate() error {
  37. return m.validate(false)
  38. }
  39. // ValidateAll checks the field values on ValueMatcher with the rules defined
  40. // in the proto definition for this message. If any rules are violated, the
  41. // result is a list of violation errors wrapped in ValueMatcherMultiError, or
  42. // nil if none found.
  43. func (m *ValueMatcher) ValidateAll() error {
  44. return m.validate(true)
  45. }
  46. func (m *ValueMatcher) validate(all bool) error {
  47. if m == nil {
  48. return nil
  49. }
  50. var errors []error
  51. switch m.MatchPattern.(type) {
  52. case *ValueMatcher_NullMatch_:
  53. if all {
  54. switch v := interface{}(m.GetNullMatch()).(type) {
  55. case interface{ ValidateAll() error }:
  56. if err := v.ValidateAll(); err != nil {
  57. errors = append(errors, ValueMatcherValidationError{
  58. field: "NullMatch",
  59. reason: "embedded message failed validation",
  60. cause: err,
  61. })
  62. }
  63. case interface{ Validate() error }:
  64. if err := v.Validate(); err != nil {
  65. errors = append(errors, ValueMatcherValidationError{
  66. field: "NullMatch",
  67. reason: "embedded message failed validation",
  68. cause: err,
  69. })
  70. }
  71. }
  72. } else if v, ok := interface{}(m.GetNullMatch()).(interface{ Validate() error }); ok {
  73. if err := v.Validate(); err != nil {
  74. return ValueMatcherValidationError{
  75. field: "NullMatch",
  76. reason: "embedded message failed validation",
  77. cause: err,
  78. }
  79. }
  80. }
  81. case *ValueMatcher_DoubleMatch:
  82. if all {
  83. switch v := interface{}(m.GetDoubleMatch()).(type) {
  84. case interface{ ValidateAll() error }:
  85. if err := v.ValidateAll(); err != nil {
  86. errors = append(errors, ValueMatcherValidationError{
  87. field: "DoubleMatch",
  88. reason: "embedded message failed validation",
  89. cause: err,
  90. })
  91. }
  92. case interface{ Validate() error }:
  93. if err := v.Validate(); err != nil {
  94. errors = append(errors, ValueMatcherValidationError{
  95. field: "DoubleMatch",
  96. reason: "embedded message failed validation",
  97. cause: err,
  98. })
  99. }
  100. }
  101. } else if v, ok := interface{}(m.GetDoubleMatch()).(interface{ Validate() error }); ok {
  102. if err := v.Validate(); err != nil {
  103. return ValueMatcherValidationError{
  104. field: "DoubleMatch",
  105. reason: "embedded message failed validation",
  106. cause: err,
  107. }
  108. }
  109. }
  110. case *ValueMatcher_StringMatch:
  111. if all {
  112. switch v := interface{}(m.GetStringMatch()).(type) {
  113. case interface{ ValidateAll() error }:
  114. if err := v.ValidateAll(); err != nil {
  115. errors = append(errors, ValueMatcherValidationError{
  116. field: "StringMatch",
  117. reason: "embedded message failed validation",
  118. cause: err,
  119. })
  120. }
  121. case interface{ Validate() error }:
  122. if err := v.Validate(); err != nil {
  123. errors = append(errors, ValueMatcherValidationError{
  124. field: "StringMatch",
  125. reason: "embedded message failed validation",
  126. cause: err,
  127. })
  128. }
  129. }
  130. } else if v, ok := interface{}(m.GetStringMatch()).(interface{ Validate() error }); ok {
  131. if err := v.Validate(); err != nil {
  132. return ValueMatcherValidationError{
  133. field: "StringMatch",
  134. reason: "embedded message failed validation",
  135. cause: err,
  136. }
  137. }
  138. }
  139. case *ValueMatcher_BoolMatch:
  140. // no validation rules for BoolMatch
  141. case *ValueMatcher_PresentMatch:
  142. // no validation rules for PresentMatch
  143. case *ValueMatcher_ListMatch:
  144. if all {
  145. switch v := interface{}(m.GetListMatch()).(type) {
  146. case interface{ ValidateAll() error }:
  147. if err := v.ValidateAll(); err != nil {
  148. errors = append(errors, ValueMatcherValidationError{
  149. field: "ListMatch",
  150. reason: "embedded message failed validation",
  151. cause: err,
  152. })
  153. }
  154. case interface{ Validate() error }:
  155. if err := v.Validate(); err != nil {
  156. errors = append(errors, ValueMatcherValidationError{
  157. field: "ListMatch",
  158. reason: "embedded message failed validation",
  159. cause: err,
  160. })
  161. }
  162. }
  163. } else if v, ok := interface{}(m.GetListMatch()).(interface{ Validate() error }); ok {
  164. if err := v.Validate(); err != nil {
  165. return ValueMatcherValidationError{
  166. field: "ListMatch",
  167. reason: "embedded message failed validation",
  168. cause: err,
  169. }
  170. }
  171. }
  172. default:
  173. err := ValueMatcherValidationError{
  174. field: "MatchPattern",
  175. reason: "value is required",
  176. }
  177. if !all {
  178. return err
  179. }
  180. errors = append(errors, err)
  181. }
  182. if len(errors) > 0 {
  183. return ValueMatcherMultiError(errors)
  184. }
  185. return nil
  186. }
  187. // ValueMatcherMultiError is an error wrapping multiple validation errors
  188. // returned by ValueMatcher.ValidateAll() if the designated constraints aren't met.
  189. type ValueMatcherMultiError []error
  190. // Error returns a concatenation of all the error messages it wraps.
  191. func (m ValueMatcherMultiError) Error() string {
  192. var msgs []string
  193. for _, err := range m {
  194. msgs = append(msgs, err.Error())
  195. }
  196. return strings.Join(msgs, "; ")
  197. }
  198. // AllErrors returns a list of validation violation errors.
  199. func (m ValueMatcherMultiError) AllErrors() []error { return m }
  200. // ValueMatcherValidationError is the validation error returned by
  201. // ValueMatcher.Validate if the designated constraints aren't met.
  202. type ValueMatcherValidationError struct {
  203. field string
  204. reason string
  205. cause error
  206. key bool
  207. }
  208. // Field function returns field value.
  209. func (e ValueMatcherValidationError) Field() string { return e.field }
  210. // Reason function returns reason value.
  211. func (e ValueMatcherValidationError) Reason() string { return e.reason }
  212. // Cause function returns cause value.
  213. func (e ValueMatcherValidationError) Cause() error { return e.cause }
  214. // Key function returns key value.
  215. func (e ValueMatcherValidationError) Key() bool { return e.key }
  216. // ErrorName returns error name.
  217. func (e ValueMatcherValidationError) ErrorName() string { return "ValueMatcherValidationError" }
  218. // Error satisfies the builtin error interface
  219. func (e ValueMatcherValidationError) Error() string {
  220. cause := ""
  221. if e.cause != nil {
  222. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  223. }
  224. key := ""
  225. if e.key {
  226. key = "key for "
  227. }
  228. return fmt.Sprintf(
  229. "invalid %sValueMatcher.%s: %s%s",
  230. key,
  231. e.field,
  232. e.reason,
  233. cause)
  234. }
  235. var _ error = ValueMatcherValidationError{}
  236. var _ interface {
  237. Field() string
  238. Reason() string
  239. Key() bool
  240. Cause() error
  241. ErrorName() string
  242. } = ValueMatcherValidationError{}
  243. // Validate checks the field values on ListMatcher with the rules defined in
  244. // the proto definition for this message. If any rules are violated, the first
  245. // error encountered is returned, or nil if there are no violations.
  246. func (m *ListMatcher) Validate() error {
  247. return m.validate(false)
  248. }
  249. // ValidateAll checks the field values on ListMatcher with the rules defined in
  250. // the proto definition for this message. If any rules are violated, the
  251. // result is a list of violation errors wrapped in ListMatcherMultiError, or
  252. // nil if none found.
  253. func (m *ListMatcher) ValidateAll() error {
  254. return m.validate(true)
  255. }
  256. func (m *ListMatcher) validate(all bool) error {
  257. if m == nil {
  258. return nil
  259. }
  260. var errors []error
  261. switch m.MatchPattern.(type) {
  262. case *ListMatcher_OneOf:
  263. if all {
  264. switch v := interface{}(m.GetOneOf()).(type) {
  265. case interface{ ValidateAll() error }:
  266. if err := v.ValidateAll(); err != nil {
  267. errors = append(errors, ListMatcherValidationError{
  268. field: "OneOf",
  269. reason: "embedded message failed validation",
  270. cause: err,
  271. })
  272. }
  273. case interface{ Validate() error }:
  274. if err := v.Validate(); err != nil {
  275. errors = append(errors, ListMatcherValidationError{
  276. field: "OneOf",
  277. reason: "embedded message failed validation",
  278. cause: err,
  279. })
  280. }
  281. }
  282. } else if v, ok := interface{}(m.GetOneOf()).(interface{ Validate() error }); ok {
  283. if err := v.Validate(); err != nil {
  284. return ListMatcherValidationError{
  285. field: "OneOf",
  286. reason: "embedded message failed validation",
  287. cause: err,
  288. }
  289. }
  290. }
  291. default:
  292. err := ListMatcherValidationError{
  293. field: "MatchPattern",
  294. reason: "value is required",
  295. }
  296. if !all {
  297. return err
  298. }
  299. errors = append(errors, err)
  300. }
  301. if len(errors) > 0 {
  302. return ListMatcherMultiError(errors)
  303. }
  304. return nil
  305. }
  306. // ListMatcherMultiError is an error wrapping multiple validation errors
  307. // returned by ListMatcher.ValidateAll() if the designated constraints aren't met.
  308. type ListMatcherMultiError []error
  309. // Error returns a concatenation of all the error messages it wraps.
  310. func (m ListMatcherMultiError) Error() string {
  311. var msgs []string
  312. for _, err := range m {
  313. msgs = append(msgs, err.Error())
  314. }
  315. return strings.Join(msgs, "; ")
  316. }
  317. // AllErrors returns a list of validation violation errors.
  318. func (m ListMatcherMultiError) AllErrors() []error { return m }
  319. // ListMatcherValidationError is the validation error returned by
  320. // ListMatcher.Validate if the designated constraints aren't met.
  321. type ListMatcherValidationError struct {
  322. field string
  323. reason string
  324. cause error
  325. key bool
  326. }
  327. // Field function returns field value.
  328. func (e ListMatcherValidationError) Field() string { return e.field }
  329. // Reason function returns reason value.
  330. func (e ListMatcherValidationError) Reason() string { return e.reason }
  331. // Cause function returns cause value.
  332. func (e ListMatcherValidationError) Cause() error { return e.cause }
  333. // Key function returns key value.
  334. func (e ListMatcherValidationError) Key() bool { return e.key }
  335. // ErrorName returns error name.
  336. func (e ListMatcherValidationError) ErrorName() string { return "ListMatcherValidationError" }
  337. // Error satisfies the builtin error interface
  338. func (e ListMatcherValidationError) Error() string {
  339. cause := ""
  340. if e.cause != nil {
  341. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  342. }
  343. key := ""
  344. if e.key {
  345. key = "key for "
  346. }
  347. return fmt.Sprintf(
  348. "invalid %sListMatcher.%s: %s%s",
  349. key,
  350. e.field,
  351. e.reason,
  352. cause)
  353. }
  354. var _ error = ListMatcherValidationError{}
  355. var _ interface {
  356. Field() string
  357. Reason() string
  358. Key() bool
  359. Cause() error
  360. ErrorName() string
  361. } = ListMatcherValidationError{}
  362. // Validate checks the field values on ValueMatcher_NullMatch with the rules
  363. // defined in the proto definition for this message. If any rules are
  364. // violated, the first error encountered is returned, or nil if there are no violations.
  365. func (m *ValueMatcher_NullMatch) Validate() error {
  366. return m.validate(false)
  367. }
  368. // ValidateAll checks the field values on ValueMatcher_NullMatch with the rules
  369. // defined in the proto definition for this message. If any rules are
  370. // violated, the result is a list of violation errors wrapped in
  371. // ValueMatcher_NullMatchMultiError, or nil if none found.
  372. func (m *ValueMatcher_NullMatch) ValidateAll() error {
  373. return m.validate(true)
  374. }
  375. func (m *ValueMatcher_NullMatch) validate(all bool) error {
  376. if m == nil {
  377. return nil
  378. }
  379. var errors []error
  380. if len(errors) > 0 {
  381. return ValueMatcher_NullMatchMultiError(errors)
  382. }
  383. return nil
  384. }
  385. // ValueMatcher_NullMatchMultiError is an error wrapping multiple validation
  386. // errors returned by ValueMatcher_NullMatch.ValidateAll() if the designated
  387. // constraints aren't met.
  388. type ValueMatcher_NullMatchMultiError []error
  389. // Error returns a concatenation of all the error messages it wraps.
  390. func (m ValueMatcher_NullMatchMultiError) Error() string {
  391. var msgs []string
  392. for _, err := range m {
  393. msgs = append(msgs, err.Error())
  394. }
  395. return strings.Join(msgs, "; ")
  396. }
  397. // AllErrors returns a list of validation violation errors.
  398. func (m ValueMatcher_NullMatchMultiError) AllErrors() []error { return m }
  399. // ValueMatcher_NullMatchValidationError is the validation error returned by
  400. // ValueMatcher_NullMatch.Validate if the designated constraints aren't met.
  401. type ValueMatcher_NullMatchValidationError struct {
  402. field string
  403. reason string
  404. cause error
  405. key bool
  406. }
  407. // Field function returns field value.
  408. func (e ValueMatcher_NullMatchValidationError) Field() string { return e.field }
  409. // Reason function returns reason value.
  410. func (e ValueMatcher_NullMatchValidationError) Reason() string { return e.reason }
  411. // Cause function returns cause value.
  412. func (e ValueMatcher_NullMatchValidationError) Cause() error { return e.cause }
  413. // Key function returns key value.
  414. func (e ValueMatcher_NullMatchValidationError) Key() bool { return e.key }
  415. // ErrorName returns error name.
  416. func (e ValueMatcher_NullMatchValidationError) ErrorName() string {
  417. return "ValueMatcher_NullMatchValidationError"
  418. }
  419. // Error satisfies the builtin error interface
  420. func (e ValueMatcher_NullMatchValidationError) Error() string {
  421. cause := ""
  422. if e.cause != nil {
  423. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  424. }
  425. key := ""
  426. if e.key {
  427. key = "key for "
  428. }
  429. return fmt.Sprintf(
  430. "invalid %sValueMatcher_NullMatch.%s: %s%s",
  431. key,
  432. e.field,
  433. e.reason,
  434. cause)
  435. }
  436. var _ error = ValueMatcher_NullMatchValidationError{}
  437. var _ interface {
  438. Field() string
  439. Reason() string
  440. Key() bool
  441. Cause() error
  442. ErrorName() string
  443. } = ValueMatcher_NullMatchValidationError{}