Debian Codegraph @

envoy/service/ratelimit/v2/rls.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/service/ratelimit/v2/rls.proto
4
5 package ratelimitv2
6
7 import (
8 "bytes"
9 "errors"
10 "fmt"
11 "net"
12 "net/mail"
13 "net/url"
14 "regexp"
15 "sort"
16 "strings"
17 "time"
18 "unicode/utf8"
19
20 "google.golang.org/protobuf/types/known/anypb"
21 )
22
23 // ensure the imports are used
24 var (
25 _ = bytes.MinRead
26 _ = errors.New("")
27 _ = fmt.Print
28 _ = utf8.UTFMax
29 _ = (*regexp.Regexp)(nil)
30 _ = (*strings.Reader)(nil)
31 _ = net.IPv4len
32 _ = time.Duration(0)
33 _ = (*url.URL)(nil)
34 _ = (*mail.Address)(nil)
35 _ = anypb.Any{}
36 _ = sort.Sort
37 )
38
39 // Validate checks the field values on RateLimitRequest with the rules defined
40 // in the proto definition for this message. If any rules are violated, the
41 // first error encountered is returned, or nil if there are no violations.
42 func (m *RateLimitRequest) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on RateLimitRequest with the rules
47 // defined in the proto definition for this message. If any rules are
48 // violated, the result is a list of violation errors wrapped in
49 // RateLimitRequestMultiError, or nil if none found.
50 func (m *RateLimitRequest) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *RateLimitRequest) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 // no validation rules for Domain
62
63 for idx, item := range m.GetDescriptors() {
64 _, _ = idx, item
65
66 if all {
67 switch v := interface{}(item).(type) {
68 case interface{ ValidateAll() error }:
69 if err := v.ValidateAll(); err != nil {
70 errors = append(errors, RateLimitRequestValidationError{
71 field: fmt.Sprintf("Descriptors[%v]", idx),
72 reason: "embedded message failed validation",
73 cause: err,
74 })
75 }
76 case interface{ Validate() error }:
77 if err := v.Validate(); err != nil {
78 errors = append(errors, RateLimitRequestValidationError{
79 field: fmt.Sprintf("Descriptors[%v]", idx),
80 reason: "embedded message failed validation",
81 cause: err,
82 })
83 }
84 }
85 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
86 if err := v.Validate(); err != nil {
87 return RateLimitRequestValidationError{
88 field: fmt.Sprintf("Descriptors[%v]", idx),
89 reason: "embedded message failed validation",
90 cause: err,
91 }
92 }
93 }
94
95 }
96
97 // no validation rules for HitsAddend
98
99 if len(errors) > 0 {
100 return RateLimitRequestMultiError(errors)
101 }
102
103 return nil
104 }
105
106 // RateLimitRequestMultiError is an error wrapping multiple validation errors
107 // returned by RateLimitRequest.ValidateAll() if the designated constraints
108 // aren't met.
109 type RateLimitRequestMultiError []error
110
111 // Error returns a concatenation of all the error messages it wraps.
112 func (m RateLimitRequestMultiError) Error() string {
113 var msgs []string
114 for _, err := range m {
115 msgs = append(msgs, err.Error())
116 }
117 return strings.Join(msgs, "; ")
118 }
119
120 // AllErrors returns a list of validation violation errors.
121 func (m RateLimitRequestMultiError) AllErrors() []error { return m }
122
123 // RateLimitRequestValidationError is the validation error returned by
124 // RateLimitRequest.Validate if the designated constraints aren't met.
125 type RateLimitRequestValidationError struct {
126 field string
127 reason string
128 cause error
129 key bool
130 }
131
132 // Field function returns field value.
133 func (e RateLimitRequestValidationError) Field() string { return e.field }
134
135 // Reason function returns reason value.
136 func (e RateLimitRequestValidationError) Reason() string { return e.reason }
137
138 // Cause function returns cause value.
139 func (e RateLimitRequestValidationError) Cause() error { return e.cause }
140
141 // Key function returns key value.
142 func (e RateLimitRequestValidationError) Key() bool { return e.key }
143
144 // ErrorName returns error name.
145 func (e RateLimitRequestValidationError) ErrorName() string { return "RateLimitRequestValidationError" }
146
147 // Error satisfies the builtin error interface
148 func (e RateLimitRequestValidationError) Error() string {
149 cause := ""
150 if e.cause != nil {
151 cause = fmt.Sprintf(" | caused by: %v", e.cause)
152 }
153
154 key := ""
155 if e.key {
156 key = "key for "
157 }
158
159 return fmt.Sprintf(
160 "invalid %sRateLimitRequest.%s: %s%s",
161 key,
162 e.field,
163 e.reason,
164 cause)
165 }
166
167 var _ error = RateLimitRequestValidationError{}
168
169 var _ interface {
170 Field() string
171 Reason() string
172 Key() bool
173 Cause() error
174 ErrorName() string
175 } = RateLimitRequestValidationError{}
176
177 // Validate checks the field values on RateLimitResponse with the rules defined
178 // in the proto definition for this message. If any rules are violated, the
179 // first error encountered is returned, or nil if there are no violations.
180 func (m *RateLimitResponse) Validate() error {
181 return m.validate(false)
182 }
183
184 // ValidateAll checks the field values on RateLimitResponse with the rules
185 // defined in the proto definition for this message. If any rules are
186 // violated, the result is a list of violation errors wrapped in
187 // RateLimitResponseMultiError, or nil if none found.
188 func (m *RateLimitResponse) ValidateAll() error {
189 return m.validate(true)
190 }
191
192 func (m *RateLimitResponse) validate(all bool) error {
193 if m == nil {
194 return nil
195 }
196
197 var errors []error
198
199 // no validation rules for OverallCode
200
201 for idx, item := range m.GetStatuses() {
202 _, _ = idx, item
203
204 if all {
205 switch v := interface{}(item).(type) {
206 case interface{ ValidateAll() error }:
207 if err := v.ValidateAll(); err != nil {
208 errors = append(errors, RateLimitResponseValidationError{
209 field: fmt.Sprintf("Statuses[%v]", idx),
210 reason: "embedded message failed validation",
211 cause: err,
212 })
213 }
214 case interface{ Validate() error }:
215 if err := v.Validate(); err != nil {
216 errors = append(errors, RateLimitResponseValidationError{
217 field: fmt.Sprintf("Statuses[%v]", idx),
218 reason: "embedded message failed validation",
219 cause: err,
220 })
221 }
222 }
223 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
224 if err := v.Validate(); err != nil {
225 return RateLimitResponseValidationError{
226 field: fmt.Sprintf("Statuses[%v]", idx),
227 reason: "embedded message failed validation",
228 cause: err,
229 }
230 }
231 }
232
233 }
234
235 for idx, item := range m.GetHeaders() {
236 _, _ = idx, item
237
238 if all {
239 switch v := interface{}(item).(type) {
240 case interface{ ValidateAll() error }:
241 if err := v.ValidateAll(); err != nil {
242 errors = append(errors, RateLimitResponseValidationError{
243 field: fmt.Sprintf("Headers[%v]", idx),
244 reason: "embedded message failed validation",
245 cause: err,
246 })
247 }
248 case interface{ Validate() error }:
249 if err := v.Validate(); err != nil {
250 errors = append(errors, RateLimitResponseValidationError{
251 field: fmt.Sprintf("Headers[%v]", idx),
252 reason: "embedded message failed validation",
253 cause: err,
254 })
255 }
256 }
257 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
258 if err := v.Validate(); err != nil {
259 return RateLimitResponseValidationError{
260 field: fmt.Sprintf("Headers[%v]", idx),
261 reason: "embedded message failed validation",
262 cause: err,
263 }
264 }
265 }
266
267 }
268
269 for idx, item := range m.GetRequestHeadersToAdd() {
270 _, _ = idx, item
271
272 if all {
273 switch v := interface{}(item).(type) {
274 case interface{ ValidateAll() error }:
275 if err := v.ValidateAll(); err != nil {
276 errors = append(errors, RateLimitResponseValidationError{
277 field: fmt.Sprintf("RequestHeadersToAdd[%v]", idx),
278 reason: "embedded message failed validation",
279 cause: err,
280 })
281 }
282 case interface{ Validate() error }:
283 if err := v.Validate(); err != nil {
284 errors = append(errors, RateLimitResponseValidationError{
285 field: fmt.Sprintf("RequestHeadersToAdd[%v]", idx),
286 reason: "embedded message failed validation",
287 cause: err,
288 })
289 }
290 }
291 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
292 if err := v.Validate(); err != nil {
293 return RateLimitResponseValidationError{
294 field: fmt.Sprintf("RequestHeadersToAdd[%v]", idx),
295 reason: "embedded message failed validation",
296 cause: err,
297 }
298 }
299 }
300
301 }
302
303 if len(errors) > 0 {
304 return RateLimitResponseMultiError(errors)
305 }
306
307 return nil
308 }
309
310 // RateLimitResponseMultiError is an error wrapping multiple validation errors
311 // returned by RateLimitResponse.ValidateAll() if the designated constraints
312 // aren't met.
313 type RateLimitResponseMultiError []error
314
315 // Error returns a concatenation of all the error messages it wraps.
316 func (m RateLimitResponseMultiError) Error() string {
317 var msgs []string
318 for _, err := range m {
319 msgs = append(msgs, err.Error())
320 }
321 return strings.Join(msgs, "; ")
322 }
323
324 // AllErrors returns a list of validation violation errors.
325 func (m RateLimitResponseMultiError) AllErrors() []error { return m }
326
327 // RateLimitResponseValidationError is the validation error returned by
328 // RateLimitResponse.Validate if the designated constraints aren't met.
329 type RateLimitResponseValidationError struct {
330 field string
331 reason string
332 cause error
333 key bool
334 }
335
336 // Field function returns field value.
337 func (e RateLimitResponseValidationError) Field() string { return e.field }
338
339 // Reason function returns reason value.
340 func (e RateLimitResponseValidationError) Reason() string { return e.reason }
341
342 // Cause function returns cause value.
343 func (e RateLimitResponseValidationError) Cause() error { return e.cause }
344
345 // Key function returns key value.
346 func (e RateLimitResponseValidationError) Key() bool { return e.key }
347
348 // ErrorName returns error name.
349 func (e RateLimitResponseValidationError) ErrorName() string {
350 return "RateLimitResponseValidationError"
351 }
352
353 // Error satisfies the builtin error interface
354 func (e RateLimitResponseValidationError) Error() string {
355 cause := ""
356 if e.cause != nil {
357 cause = fmt.Sprintf(" | caused by: %v", e.cause)
358 }
359
360 key := ""
361 if e.key {
362 key = "key for "
363 }
364
365 return fmt.Sprintf(
366 "invalid %sRateLimitResponse.%s: %s%s",
367 key,
368 e.field,
369 e.reason,
370 cause)
371 }
372
373 var _ error = RateLimitResponseValidationError{}
374
375 var _ interface {
376 Field() string
377 Reason() string
378 Key() bool
379 Cause() error
380 ErrorName() string
381 } = RateLimitResponseValidationError{}
382
383 // Validate checks the field values on RateLimitResponse_RateLimit with the
384 // rules defined in the proto definition for this message. If any rules are
385 // violated, the first error encountered is returned, or nil if there are no violations.
386 func (m *RateLimitResponse_RateLimit) Validate() error {
387 return m.validate(false)
388 }
389
390 // ValidateAll checks the field values on RateLimitResponse_RateLimit with the
391 // rules defined in the proto definition for this message. If any rules are
392 // violated, the result is a list of violation errors wrapped in
393 // RateLimitResponse_RateLimitMultiError, or nil if none found.
394 func (m *RateLimitResponse_RateLimit) ValidateAll() error {
395 return m.validate(true)
396 }
397
398 func (m *RateLimitResponse_RateLimit) validate(all bool) error {
399 if m == nil {
400 return nil
401 }
402
403 var errors []error
404
405 // no validation rules for Name
406
407 // no validation rules for RequestsPerUnit
408
409 // no validation rules for Unit
410
411 if len(errors) > 0 {
412 return RateLimitResponse_RateLimitMultiError(errors)
413 }
414
415 return nil
416 }
417
418 // RateLimitResponse_RateLimitMultiError is an error wrapping multiple
419 // validation errors returned by RateLimitResponse_RateLimit.ValidateAll() if
420 // the designated constraints aren't met.
421 type RateLimitResponse_RateLimitMultiError []error
422
423 // Error returns a concatenation of all the error messages it wraps.
424 func (m RateLimitResponse_RateLimitMultiError) Error() string {
425 var msgs []string
426 for _, err := range m {
427 msgs = append(msgs, err.Error())
428 }
429 return strings.Join(msgs, "; ")
430 }
431
432 // AllErrors returns a list of validation violation errors.
433 func (m RateLimitResponse_RateLimitMultiError) AllErrors() []error { return m }
434
435 // RateLimitResponse_RateLimitValidationError is the validation error returned
436 // by RateLimitResponse_RateLimit.Validate if the designated constraints
437 // aren't met.
438 type RateLimitResponse_RateLimitValidationError struct {
439 field string
440 reason string
441 cause error
442 key bool
443 }
444
445 // Field function returns field value.
446 func (e RateLimitResponse_RateLimitValidationError) Field() string { return e.field }
447
448 // Reason function returns reason value.
449 func (e RateLimitResponse_RateLimitValidationError) Reason() string { return e.reason }
450
451 // Cause function returns cause value.
452 func (e RateLimitResponse_RateLimitValidationError) Cause() error { return e.cause }
453
454 // Key function returns key value.
455 func (e RateLimitResponse_RateLimitValidationError) Key() bool { return e.key }
456
457 // ErrorName returns error name.
458 func (e RateLimitResponse_RateLimitValidationError) ErrorName() string {
459 return "RateLimitResponse_RateLimitValidationError"
460 }
461
462 // Error satisfies the builtin error interface
463 func (e RateLimitResponse_RateLimitValidationError) Error() string {
464 cause := ""
465 if e.cause != nil {
466 cause = fmt.Sprintf(" | caused by: %v", e.cause)
467 }
468
469 key := ""
470 if e.key {
471 key = "key for "
472 }
473
474 return fmt.Sprintf(
475 "invalid %sRateLimitResponse_RateLimit.%s: %s%s",
476 key,
477 e.field,
478 e.reason,
479 cause)
480 }
481
482 var _ error = RateLimitResponse_RateLimitValidationError{}
483
484 var _ interface {
485 Field() string
486 Reason() string
487 Key() bool
488 Cause() error
489 ErrorName() string
490 } = RateLimitResponse_RateLimitValidationError{}
491
492 // Validate checks the field values on RateLimitResponse_DescriptorStatus with
493 // the rules defined in the proto definition for this message. If any rules
494 // are violated, the first error encountered is returned, or nil if there are
495 // no violations.
496 func (m *RateLimitResponse_DescriptorStatus) Validate() error {
497 return m.validate(false)
498 }
499
500 // ValidateAll checks the field values on RateLimitResponse_DescriptorStatus
501 // with the rules defined in the proto definition for this message. If any
502 // rules are violated, the result is a list of violation errors wrapped in
503 // RateLimitResponse_DescriptorStatusMultiError, or nil if none found.
504 func (m *RateLimitResponse_DescriptorStatus) ValidateAll() error {
505 return m.validate(true)
506 }
507
508 func (m *RateLimitResponse_DescriptorStatus) validate(all bool) error {
509 if m == nil {
510 return nil
511 }
512
513 var errors []error
514
515 // no validation rules for Code
516
517 if all {
518 switch v := interface{}(m.GetCurrentLimit()).(type) {
519 case interface{ ValidateAll() error }:
520 if err := v.ValidateAll(); err != nil {
521 errors = append(errors, RateLimitResponse_DescriptorStatusValidationError{
522 field: "CurrentLimit",
523 reason: "embedded message failed validation",
524 cause: err,
525 })
526 }
527 case interface{ Validate() error }:
528 if err := v.Validate(); err != nil {
529 errors = append(errors, RateLimitResponse_DescriptorStatusValidationError{
530 field: "CurrentLimit",
531 reason: "embedded message failed validation",
532 cause: err,
533 })
534 }
535 }
536 } else if v, ok := interface{}(m.GetCurrentLimit()).(interface{ Validate() error }); ok {
537 if err := v.Validate(); err != nil {
538 return RateLimitResponse_DescriptorStatusValidationError{
539 field: "CurrentLimit",
540 reason: "embedded message failed validation",
541 cause: err,
542 }
543 }
544 }
545
546 // no validation rules for LimitRemaining
547
548 if len(errors) > 0 {
549 return RateLimitResponse_DescriptorStatusMultiError(errors)
550 }
551
552 return nil
553 }
554
555 // RateLimitResponse_DescriptorStatusMultiError is an error wrapping multiple
556 // validation errors returned by
557 // RateLimitResponse_DescriptorStatus.ValidateAll() if the designated
558 // constraints aren't met.
559 type RateLimitResponse_DescriptorStatusMultiError []error
560
561 // Error returns a concatenation of all the error messages it wraps.
562 func (m RateLimitResponse_DescriptorStatusMultiError) Error() string {
563 var msgs []string
564 for _, err := range m {
565 msgs = append(msgs, err.Error())
566 }
567 return strings.Join(msgs, "; ")
568 }
569
570 // AllErrors returns a list of validation violation errors.
571 func (m RateLimitResponse_DescriptorStatusMultiError) AllErrors() []error { return m }
572
573 // RateLimitResponse_DescriptorStatusValidationError is the validation error
574 // returned by RateLimitResponse_DescriptorStatus.Validate if the designated
575 // constraints aren't met.
576 type RateLimitResponse_DescriptorStatusValidationError struct {
577 field string
578 reason string
579 cause error
580 key bool
581 }
582
583 // Field function returns field value.
584 func (e RateLimitResponse_DescriptorStatusValidationError) Field() string { return e.field }
585
586 // Reason function returns reason value.
587 func (e RateLimitResponse_DescriptorStatusValidationError) Reason() string { return e.reason }
588
589 // Cause function returns cause value.
590 func (e RateLimitResponse_DescriptorStatusValidationError) Cause() error { return e.cause }
591
592 // Key function returns key value.
593 func (e RateLimitResponse_DescriptorStatusValidationError) Key() bool { return e.key }
594
595 // ErrorName returns error name.
596 func (e RateLimitResponse_DescriptorStatusValidationError) ErrorName() string {
597 return "RateLimitResponse_DescriptorStatusValidationError"
598 }
599
600 // Error satisfies the builtin error interface
601 func (e RateLimitResponse_DescriptorStatusValidationError) Error() string {
602 cause := ""
603 if e.cause != nil {
604 cause = fmt.Sprintf(" | caused by: %v", e.cause)
605 }
606
607 key := ""
608 if e.key {
609 key = "key for "
610 }
611
612 return fmt.Sprintf(
613 "invalid %sRateLimitResponse_DescriptorStatus.%s: %s%s",
614 key,
615 e.field,
616 e.reason,
617 cause)
618 }
619
620 var _ error = RateLimitResponse_DescriptorStatusValidationError{}
621
622 var _ interface {
623 Field() string
624 Reason() string
625 Key() bool
626 Cause() error
627 ErrorName() string
628 } = RateLimitResponse_DescriptorStatusValidationError{}