Debian Codegraph @

envoy/service/auth/v2/external_auth.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/service/auth/v2/external_auth.proto
4
5 package authv2
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 CheckRequest with the rules defined in
40 // the proto definition for this message. If any rules are violated, the first
41 // error encountered is returned, or nil if there are no violations.
42 func (m *CheckRequest) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on CheckRequest with the rules defined
47 // in the proto definition for this message. If any rules are violated, the
48 // result is a list of violation errors wrapped in CheckRequestMultiError, or
49 // nil if none found.
50 func (m *CheckRequest) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *CheckRequest) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 if all {
62 switch v := interface{}(m.GetAttributes()).(type) {
63 case interface{ ValidateAll() error }:
64 if err := v.ValidateAll(); err != nil {
65 errors = append(errors, CheckRequestValidationError{
66 field: "Attributes",
67 reason: "embedded message failed validation",
68 cause: err,
69 })
70 }
71 case interface{ Validate() error }:
72 if err := v.Validate(); err != nil {
73 errors = append(errors, CheckRequestValidationError{
74 field: "Attributes",
75 reason: "embedded message failed validation",
76 cause: err,
77 })
78 }
79 }
80 } else if v, ok := interface{}(m.GetAttributes()).(interface{ Validate() error }); ok {
81 if err := v.Validate(); err != nil {
82 return CheckRequestValidationError{
83 field: "Attributes",
84 reason: "embedded message failed validation",
85 cause: err,
86 }
87 }
88 }
89
90 if len(errors) > 0 {
91 return CheckRequestMultiError(errors)
92 }
93
94 return nil
95 }
96
97 // CheckRequestMultiError is an error wrapping multiple validation errors
98 // returned by CheckRequest.ValidateAll() if the designated constraints aren't met.
99 type CheckRequestMultiError []error
100
101 // Error returns a concatenation of all the error messages it wraps.
102 func (m CheckRequestMultiError) Error() string {
103 var msgs []string
104 for _, err := range m {
105 msgs = append(msgs, err.Error())
106 }
107 return strings.Join(msgs, "; ")
108 }
109
110 // AllErrors returns a list of validation violation errors.
111 func (m CheckRequestMultiError) AllErrors() []error { return m }
112
113 // CheckRequestValidationError is the validation error returned by
114 // CheckRequest.Validate if the designated constraints aren't met.
115 type CheckRequestValidationError struct {
116 field string
117 reason string
118 cause error
119 key bool
120 }
121
122 // Field function returns field value.
123 func (e CheckRequestValidationError) Field() string { return e.field }
124
125 // Reason function returns reason value.
126 func (e CheckRequestValidationError) Reason() string { return e.reason }
127
128 // Cause function returns cause value.
129 func (e CheckRequestValidationError) Cause() error { return e.cause }
130
131 // Key function returns key value.
132 func (e CheckRequestValidationError) Key() bool { return e.key }
133
134 // ErrorName returns error name.
135 func (e CheckRequestValidationError) ErrorName() string { return "CheckRequestValidationError" }
136
137 // Error satisfies the builtin error interface
138 func (e CheckRequestValidationError) Error() string {
139 cause := ""
140 if e.cause != nil {
141 cause = fmt.Sprintf(" | caused by: %v", e.cause)
142 }
143
144 key := ""
145 if e.key {
146 key = "key for "
147 }
148
149 return fmt.Sprintf(
150 "invalid %sCheckRequest.%s: %s%s",
151 key,
152 e.field,
153 e.reason,
154 cause)
155 }
156
157 var _ error = CheckRequestValidationError{}
158
159 var _ interface {
160 Field() string
161 Reason() string
162 Key() bool
163 Cause() error
164 ErrorName() string
165 } = CheckRequestValidationError{}
166
167 // Validate checks the field values on DeniedHttpResponse with the rules
168 // defined in the proto definition for this message. If any rules are
169 // violated, the first error encountered is returned, or nil if there are no violations.
170 func (m *DeniedHttpResponse) Validate() error {
171 return m.validate(false)
172 }
173
174 // ValidateAll checks the field values on DeniedHttpResponse with the rules
175 // defined in the proto definition for this message. If any rules are
176 // violated, the result is a list of violation errors wrapped in
177 // DeniedHttpResponseMultiError, or nil if none found.
178 func (m *DeniedHttpResponse) ValidateAll() error {
179 return m.validate(true)
180 }
181
182 func (m *DeniedHttpResponse) validate(all bool) error {
183 if m == nil {
184 return nil
185 }
186
187 var errors []error
188
189 if m.GetStatus() == nil {
190 err := DeniedHttpResponseValidationError{
191 field: "Status",
192 reason: "value is required",
193 }
194 if !all {
195 return err
196 }
197 errors = append(errors, err)
198 }
199
200 if all {
201 switch v := interface{}(m.GetStatus()).(type) {
202 case interface{ ValidateAll() error }:
203 if err := v.ValidateAll(); err != nil {
204 errors = append(errors, DeniedHttpResponseValidationError{
205 field: "Status",
206 reason: "embedded message failed validation",
207 cause: err,
208 })
209 }
210 case interface{ Validate() error }:
211 if err := v.Validate(); err != nil {
212 errors = append(errors, DeniedHttpResponseValidationError{
213 field: "Status",
214 reason: "embedded message failed validation",
215 cause: err,
216 })
217 }
218 }
219 } else if v, ok := interface{}(m.GetStatus()).(interface{ Validate() error }); ok {
220 if err := v.Validate(); err != nil {
221 return DeniedHttpResponseValidationError{
222 field: "Status",
223 reason: "embedded message failed validation",
224 cause: err,
225 }
226 }
227 }
228
229 for idx, item := range m.GetHeaders() {
230 _, _ = idx, item
231
232 if all {
233 switch v := interface{}(item).(type) {
234 case interface{ ValidateAll() error }:
235 if err := v.ValidateAll(); err != nil {
236 errors = append(errors, DeniedHttpResponseValidationError{
237 field: fmt.Sprintf("Headers[%v]", idx),
238 reason: "embedded message failed validation",
239 cause: err,
240 })
241 }
242 case interface{ Validate() error }:
243 if err := v.Validate(); err != nil {
244 errors = append(errors, DeniedHttpResponseValidationError{
245 field: fmt.Sprintf("Headers[%v]", idx),
246 reason: "embedded message failed validation",
247 cause: err,
248 })
249 }
250 }
251 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
252 if err := v.Validate(); err != nil {
253 return DeniedHttpResponseValidationError{
254 field: fmt.Sprintf("Headers[%v]", idx),
255 reason: "embedded message failed validation",
256 cause: err,
257 }
258 }
259 }
260
261 }
262
263 // no validation rules for Body
264
265 if len(errors) > 0 {
266 return DeniedHttpResponseMultiError(errors)
267 }
268
269 return nil
270 }
271
272 // DeniedHttpResponseMultiError is an error wrapping multiple validation errors
273 // returned by DeniedHttpResponse.ValidateAll() if the designated constraints
274 // aren't met.
275 type DeniedHttpResponseMultiError []error
276
277 // Error returns a concatenation of all the error messages it wraps.
278 func (m DeniedHttpResponseMultiError) Error() string {
279 var msgs []string
280 for _, err := range m {
281 msgs = append(msgs, err.Error())
282 }
283 return strings.Join(msgs, "; ")
284 }
285
286 // AllErrors returns a list of validation violation errors.
287 func (m DeniedHttpResponseMultiError) AllErrors() []error { return m }
288
289 // DeniedHttpResponseValidationError is the validation error returned by
290 // DeniedHttpResponse.Validate if the designated constraints aren't met.
291 type DeniedHttpResponseValidationError struct {
292 field string
293 reason string
294 cause error
295 key bool
296 }
297
298 // Field function returns field value.
299 func (e DeniedHttpResponseValidationError) Field() string { return e.field }
300
301 // Reason function returns reason value.
302 func (e DeniedHttpResponseValidationError) Reason() string { return e.reason }
303
304 // Cause function returns cause value.
305 func (e DeniedHttpResponseValidationError) Cause() error { return e.cause }
306
307 // Key function returns key value.
308 func (e DeniedHttpResponseValidationError) Key() bool { return e.key }
309
310 // ErrorName returns error name.
311 func (e DeniedHttpResponseValidationError) ErrorName() string {
312 return "DeniedHttpResponseValidationError"
313 }
314
315 // Error satisfies the builtin error interface
316 func (e DeniedHttpResponseValidationError) Error() string {
317 cause := ""
318 if e.cause != nil {
319 cause = fmt.Sprintf(" | caused by: %v", e.cause)
320 }
321
322 key := ""
323 if e.key {
324 key = "key for "
325 }
326
327 return fmt.Sprintf(
328 "invalid %sDeniedHttpResponse.%s: %s%s",
329 key,
330 e.field,
331 e.reason,
332 cause)
333 }
334
335 var _ error = DeniedHttpResponseValidationError{}
336
337 var _ interface {
338 Field() string
339 Reason() string
340 Key() bool
341 Cause() error
342 ErrorName() string
343 } = DeniedHttpResponseValidationError{}
344
345 // Validate checks the field values on OkHttpResponse with the rules defined in
346 // the proto definition for this message. If any rules are violated, the first
347 // error encountered is returned, or nil if there are no violations.
348 func (m *OkHttpResponse) Validate() error {
349 return m.validate(false)
350 }
351
352 // ValidateAll checks the field values on OkHttpResponse with the rules defined
353 // in the proto definition for this message. If any rules are violated, the
354 // result is a list of violation errors wrapped in OkHttpResponseMultiError,
355 // or nil if none found.
356 func (m *OkHttpResponse) ValidateAll() error {
357 return m.validate(true)
358 }
359
360 func (m *OkHttpResponse) validate(all bool) error {
361 if m == nil {
362 return nil
363 }
364
365 var errors []error
366
367 for idx, item := range m.GetHeaders() {
368 _, _ = idx, item
369
370 if all {
371 switch v := interface{}(item).(type) {
372 case interface{ ValidateAll() error }:
373 if err := v.ValidateAll(); err != nil {
374 errors = append(errors, OkHttpResponseValidationError{
375 field: fmt.Sprintf("Headers[%v]", idx),
376 reason: "embedded message failed validation",
377 cause: err,
378 })
379 }
380 case interface{ Validate() error }:
381 if err := v.Validate(); err != nil {
382 errors = append(errors, OkHttpResponseValidationError{
383 field: fmt.Sprintf("Headers[%v]", idx),
384 reason: "embedded message failed validation",
385 cause: err,
386 })
387 }
388 }
389 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
390 if err := v.Validate(); err != nil {
391 return OkHttpResponseValidationError{
392 field: fmt.Sprintf("Headers[%v]", idx),
393 reason: "embedded message failed validation",
394 cause: err,
395 }
396 }
397 }
398
399 }
400
401 if len(errors) > 0 {
402 return OkHttpResponseMultiError(errors)
403 }
404
405 return nil
406 }
407
408 // OkHttpResponseMultiError is an error wrapping multiple validation errors
409 // returned by OkHttpResponse.ValidateAll() if the designated constraints
410 // aren't met.
411 type OkHttpResponseMultiError []error
412
413 // Error returns a concatenation of all the error messages it wraps.
414 func (m OkHttpResponseMultiError) Error() string {
415 var msgs []string
416 for _, err := range m {
417 msgs = append(msgs, err.Error())
418 }
419 return strings.Join(msgs, "; ")
420 }
421
422 // AllErrors returns a list of validation violation errors.
423 func (m OkHttpResponseMultiError) AllErrors() []error { return m }
424
425 // OkHttpResponseValidationError is the validation error returned by
426 // OkHttpResponse.Validate if the designated constraints aren't met.
427 type OkHttpResponseValidationError struct {
428 field string
429 reason string
430 cause error
431 key bool
432 }
433
434 // Field function returns field value.
435 func (e OkHttpResponseValidationError) Field() string { return e.field }
436
437 // Reason function returns reason value.
438 func (e OkHttpResponseValidationError) Reason() string { return e.reason }
439
440 // Cause function returns cause value.
441 func (e OkHttpResponseValidationError) Cause() error { return e.cause }
442
443 // Key function returns key value.
444 func (e OkHttpResponseValidationError) Key() bool { return e.key }
445
446 // ErrorName returns error name.
447 func (e OkHttpResponseValidationError) ErrorName() string { return "OkHttpResponseValidationError" }
448
449 // Error satisfies the builtin error interface
450 func (e OkHttpResponseValidationError) Error() string {
451 cause := ""
452 if e.cause != nil {
453 cause = fmt.Sprintf(" | caused by: %v", e.cause)
454 }
455
456 key := ""
457 if e.key {
458 key = "key for "
459 }
460
461 return fmt.Sprintf(
462 "invalid %sOkHttpResponse.%s: %s%s",
463 key,
464 e.field,
465 e.reason,
466 cause)
467 }
468
469 var _ error = OkHttpResponseValidationError{}
470
471 var _ interface {
472 Field() string
473 Reason() string
474 Key() bool
475 Cause() error
476 ErrorName() string
477 } = OkHttpResponseValidationError{}
478
479 // Validate checks the field values on CheckResponse with the rules defined in
480 // the proto definition for this message. If any rules are violated, the first
481 // error encountered is returned, or nil if there are no violations.
482 func (m *CheckResponse) Validate() error {
483 return m.validate(false)
484 }
485
486 // ValidateAll checks the field values on CheckResponse with the rules defined
487 // in the proto definition for this message. If any rules are violated, the
488 // result is a list of violation errors wrapped in CheckResponseMultiError, or
489 // nil if none found.
490 func (m *CheckResponse) ValidateAll() error {
491 return m.validate(true)
492 }
493
494 func (m *CheckResponse) validate(all bool) error {
495 if m == nil {
496 return nil
497 }
498
499 var errors []error
500
501 if all {
502 switch v := interface{}(m.GetStatus()).(type) {
503 case interface{ ValidateAll() error }:
504 if err := v.ValidateAll(); err != nil {
505 errors = append(errors, CheckResponseValidationError{
506 field: "Status",
507 reason: "embedded message failed validation",
508 cause: err,
509 })
510 }
511 case interface{ Validate() error }:
512 if err := v.Validate(); err != nil {
513 errors = append(errors, CheckResponseValidationError{
514 field: "Status",
515 reason: "embedded message failed validation",
516 cause: err,
517 })
518 }
519 }
520 } else if v, ok := interface{}(m.GetStatus()).(interface{ Validate() error }); ok {
521 if err := v.Validate(); err != nil {
522 return CheckResponseValidationError{
523 field: "Status",
524 reason: "embedded message failed validation",
525 cause: err,
526 }
527 }
528 }
529
530 switch v := m.HttpResponse.(type) {
531 case *CheckResponse_DeniedResponse:
532 if v == nil {
533 err := CheckResponseValidationError{
534 field: "HttpResponse",
535 reason: "oneof value cannot be a typed-nil",
536 }
537 if !all {
538 return err
539 }
540 errors = append(errors, err)
541 }
542
543 if all {
544 switch v := interface{}(m.GetDeniedResponse()).(type) {
545 case interface{ ValidateAll() error }:
546 if err := v.ValidateAll(); err != nil {
547 errors = append(errors, CheckResponseValidationError{
548 field: "DeniedResponse",
549 reason: "embedded message failed validation",
550 cause: err,
551 })
552 }
553 case interface{ Validate() error }:
554 if err := v.Validate(); err != nil {
555 errors = append(errors, CheckResponseValidationError{
556 field: "DeniedResponse",
557 reason: "embedded message failed validation",
558 cause: err,
559 })
560 }
561 }
562 } else if v, ok := interface{}(m.GetDeniedResponse()).(interface{ Validate() error }); ok {
563 if err := v.Validate(); err != nil {
564 return CheckResponseValidationError{
565 field: "DeniedResponse",
566 reason: "embedded message failed validation",
567 cause: err,
568 }
569 }
570 }
571
572 case *CheckResponse_OkResponse:
573 if v == nil {
574 err := CheckResponseValidationError{
575 field: "HttpResponse",
576 reason: "oneof value cannot be a typed-nil",
577 }
578 if !all {
579 return err
580 }
581 errors = append(errors, err)
582 }
583
584 if all {
585 switch v := interface{}(m.GetOkResponse()).(type) {
586 case interface{ ValidateAll() error }:
587 if err := v.ValidateAll(); err != nil {
588 errors = append(errors, CheckResponseValidationError{
589 field: "OkResponse",
590 reason: "embedded message failed validation",
591 cause: err,
592 })
593 }
594 case interface{ Validate() error }:
595 if err := v.Validate(); err != nil {
596 errors = append(errors, CheckResponseValidationError{
597 field: "OkResponse",
598 reason: "embedded message failed validation",
599 cause: err,
600 })
601 }
602 }
603 } else if v, ok := interface{}(m.GetOkResponse()).(interface{ Validate() error }); ok {
604 if err := v.Validate(); err != nil {
605 return CheckResponseValidationError{
606 field: "OkResponse",
607 reason: "embedded message failed validation",
608 cause: err,
609 }
610 }
611 }
612
613 default:
614 _ = v // ensures v is used
615 }
616
617 if len(errors) > 0 {
618 return CheckResponseMultiError(errors)
619 }
620
621 return nil
622 }
623
624 // CheckResponseMultiError is an error wrapping multiple validation errors
625 // returned by CheckResponse.ValidateAll() if the designated constraints
626 // aren't met.
627 type CheckResponseMultiError []error
628
629 // Error returns a concatenation of all the error messages it wraps.
630 func (m CheckResponseMultiError) Error() string {
631 var msgs []string
632 for _, err := range m {
633 msgs = append(msgs, err.Error())
634 }
635 return strings.Join(msgs, "; ")
636 }
637
638 // AllErrors returns a list of validation violation errors.
639 func (m CheckResponseMultiError) AllErrors() []error { return m }
640
641 // CheckResponseValidationError is the validation error returned by
642 // CheckResponse.Validate if the designated constraints aren't met.
643 type CheckResponseValidationError struct {
644 field string
645 reason string
646 cause error
647 key bool
648 }
649
650 // Field function returns field value.
651 func (e CheckResponseValidationError) Field() string { return e.field }
652
653 // Reason function returns reason value.
654 func (e CheckResponseValidationError) Reason() string { return e.reason }
655
656 // Cause function returns cause value.
657 func (e CheckResponseValidationError) Cause() error { return e.cause }
658
659 // Key function returns key value.
660 func (e CheckResponseValidationError) Key() bool { return e.key }
661
662 // ErrorName returns error name.
663 func (e CheckResponseValidationError) ErrorName() string { return "CheckResponseValidationError" }
664
665 // Error satisfies the builtin error interface
666 func (e CheckResponseValidationError) Error() string {
667 cause := ""
668 if e.cause != nil {
669 cause = fmt.Sprintf(" | caused by: %v", e.cause)
670 }
671
672 key := ""
673 if e.key {
674 key = "key for "
675 }
676
677 return fmt.Sprintf(
678 "invalid %sCheckResponse.%s: %s%s",
679 key,
680 e.field,
681 e.reason,
682 cause)
683 }
684
685 var _ error = CheckResponseValidationError{}
686
687 var _ interface {
688 Field() string
689 Reason() string
690 Key() bool
691 Cause() error
692 ErrorName() string
693 } = CheckResponseValidationError{}