Debian Codegraph @

envoy/config/core/v3/address.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/core/v3/address.proto
4
5 package corev3
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 Pipe with the rules defined in the proto
40 // definition for this message. If any rules are violated, the first error
41 // encountered is returned, or nil if there are no violations.
42 func (m *Pipe) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on Pipe with the rules defined in the
47 // proto definition for this message. If any rules are violated, the result is
48 // a list of violation errors wrapped in PipeMultiError, or nil if none found.
49 func (m *Pipe) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *Pipe) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 if utf8.RuneCountInString(m.GetPath()) < 1 {
61 err := PipeValidationError{
62 field: "Path",
63 reason: "value length must be at least 1 runes",
64 }
65 if !all {
66 return err
67 }
68 errors = append(errors, err)
69 }
70
71 if m.GetMode() > 511 {
72 err := PipeValidationError{
73 field: "Mode",
74 reason: "value must be less than or equal to 511",
75 }
76 if !all {
77 return err
78 }
79 errors = append(errors, err)
80 }
81
82 if len(errors) > 0 {
83 return PipeMultiError(errors)
84 }
85
86 return nil
87 }
88
89 // PipeMultiError is an error wrapping multiple validation errors returned by
90 // Pipe.ValidateAll() if the designated constraints aren't met.
91 type PipeMultiError []error
92
93 // Error returns a concatenation of all the error messages it wraps.
94 func (m PipeMultiError) Error() string {
95 var msgs []string
96 for _, err := range m {
97 msgs = append(msgs, err.Error())
98 }
99 return strings.Join(msgs, "; ")
100 }
101
102 // AllErrors returns a list of validation violation errors.
103 func (m PipeMultiError) AllErrors() []error { return m }
104
105 // PipeValidationError is the validation error returned by Pipe.Validate if the
106 // designated constraints aren't met.
107 type PipeValidationError struct {
108 field string
109 reason string
110 cause error
111 key bool
112 }
113
114 // Field function returns field value.
115 func (e PipeValidationError) Field() string { return e.field }
116
117 // Reason function returns reason value.
118 func (e PipeValidationError) Reason() string { return e.reason }
119
120 // Cause function returns cause value.
121 func (e PipeValidationError) Cause() error { return e.cause }
122
123 // Key function returns key value.
124 func (e PipeValidationError) Key() bool { return e.key }
125
126 // ErrorName returns error name.
127 func (e PipeValidationError) ErrorName() string { return "PipeValidationError" }
128
129 // Error satisfies the builtin error interface
130 func (e PipeValidationError) Error() string {
131 cause := ""
132 if e.cause != nil {
133 cause = fmt.Sprintf(" | caused by: %v", e.cause)
134 }
135
136 key := ""
137 if e.key {
138 key = "key for "
139 }
140
141 return fmt.Sprintf(
142 "invalid %sPipe.%s: %s%s",
143 key,
144 e.field,
145 e.reason,
146 cause)
147 }
148
149 var _ error = PipeValidationError{}
150
151 var _ interface {
152 Field() string
153 Reason() string
154 Key() bool
155 Cause() error
156 ErrorName() string
157 } = PipeValidationError{}
158
159 // Validate checks the field values on EnvoyInternalAddress with the rules
160 // defined in the proto definition for this message. If any rules are
161 // violated, the first error encountered is returned, or nil if there are no violations.
162 func (m *EnvoyInternalAddress) Validate() error {
163 return m.validate(false)
164 }
165
166 // ValidateAll checks the field values on EnvoyInternalAddress with the rules
167 // defined in the proto definition for this message. If any rules are
168 // violated, the result is a list of violation errors wrapped in
169 // EnvoyInternalAddressMultiError, or nil if none found.
170 func (m *EnvoyInternalAddress) ValidateAll() error {
171 return m.validate(true)
172 }
173
174 func (m *EnvoyInternalAddress) validate(all bool) error {
175 if m == nil {
176 return nil
177 }
178
179 var errors []error
180
181 // no validation rules for EndpointId
182
183 oneofAddressNameSpecifierPresent := false
184 switch v := m.AddressNameSpecifier.(type) {
185 case *EnvoyInternalAddress_ServerListenerName:
186 if v == nil {
187 err := EnvoyInternalAddressValidationError{
188 field: "AddressNameSpecifier",
189 reason: "oneof value cannot be a typed-nil",
190 }
191 if !all {
192 return err
193 }
194 errors = append(errors, err)
195 }
196 oneofAddressNameSpecifierPresent = true
197 // no validation rules for ServerListenerName
198 default:
199 _ = v // ensures v is used
200 }
201 if !oneofAddressNameSpecifierPresent {
202 err := EnvoyInternalAddressValidationError{
203 field: "AddressNameSpecifier",
204 reason: "value is required",
205 }
206 if !all {
207 return err
208 }
209 errors = append(errors, err)
210 }
211
212 if len(errors) > 0 {
213 return EnvoyInternalAddressMultiError(errors)
214 }
215
216 return nil
217 }
218
219 // EnvoyInternalAddressMultiError is an error wrapping multiple validation
220 // errors returned by EnvoyInternalAddress.ValidateAll() if the designated
221 // constraints aren't met.
222 type EnvoyInternalAddressMultiError []error
223
224 // Error returns a concatenation of all the error messages it wraps.
225 func (m EnvoyInternalAddressMultiError) Error() string {
226 var msgs []string
227 for _, err := range m {
228 msgs = append(msgs, err.Error())
229 }
230 return strings.Join(msgs, "; ")
231 }
232
233 // AllErrors returns a list of validation violation errors.
234 func (m EnvoyInternalAddressMultiError) AllErrors() []error { return m }
235
236 // EnvoyInternalAddressValidationError is the validation error returned by
237 // EnvoyInternalAddress.Validate if the designated constraints aren't met.
238 type EnvoyInternalAddressValidationError struct {
239 field string
240 reason string
241 cause error
242 key bool
243 }
244
245 // Field function returns field value.
246 func (e EnvoyInternalAddressValidationError) Field() string { return e.field }
247
248 // Reason function returns reason value.
249 func (e EnvoyInternalAddressValidationError) Reason() string { return e.reason }
250
251 // Cause function returns cause value.
252 func (e EnvoyInternalAddressValidationError) Cause() error { return e.cause }
253
254 // Key function returns key value.
255 func (e EnvoyInternalAddressValidationError) Key() bool { return e.key }
256
257 // ErrorName returns error name.
258 func (e EnvoyInternalAddressValidationError) ErrorName() string {
259 return "EnvoyInternalAddressValidationError"
260 }
261
262 // Error satisfies the builtin error interface
263 func (e EnvoyInternalAddressValidationError) Error() string {
264 cause := ""
265 if e.cause != nil {
266 cause = fmt.Sprintf(" | caused by: %v", e.cause)
267 }
268
269 key := ""
270 if e.key {
271 key = "key for "
272 }
273
274 return fmt.Sprintf(
275 "invalid %sEnvoyInternalAddress.%s: %s%s",
276 key,
277 e.field,
278 e.reason,
279 cause)
280 }
281
282 var _ error = EnvoyInternalAddressValidationError{}
283
284 var _ interface {
285 Field() string
286 Reason() string
287 Key() bool
288 Cause() error
289 ErrorName() string
290 } = EnvoyInternalAddressValidationError{}
291
292 // Validate checks the field values on SocketAddress with the rules defined in
293 // the proto definition for this message. If any rules are violated, the first
294 // error encountered is returned, or nil if there are no violations.
295 func (m *SocketAddress) Validate() error {
296 return m.validate(false)
297 }
298
299 // ValidateAll checks the field values on SocketAddress with the rules defined
300 // in the proto definition for this message. If any rules are violated, the
301 // result is a list of violation errors wrapped in SocketAddressMultiError, or
302 // nil if none found.
303 func (m *SocketAddress) ValidateAll() error {
304 return m.validate(true)
305 }
306
307 func (m *SocketAddress) validate(all bool) error {
308 if m == nil {
309 return nil
310 }
311
312 var errors []error
313
314 if _, ok := SocketAddress_Protocol_name[int32(m.GetProtocol())]; !ok {
315 err := SocketAddressValidationError{
316 field: "Protocol",
317 reason: "value must be one of the defined enum values",
318 }
319 if !all {
320 return err
321 }
322 errors = append(errors, err)
323 }
324
325 if utf8.RuneCountInString(m.GetAddress()) < 1 {
326 err := SocketAddressValidationError{
327 field: "Address",
328 reason: "value length must be at least 1 runes",
329 }
330 if !all {
331 return err
332 }
333 errors = append(errors, err)
334 }
335
336 // no validation rules for ResolverName
337
338 // no validation rules for Ipv4Compat
339
340 oneofPortSpecifierPresent := false
341 switch v := m.PortSpecifier.(type) {
342 case *SocketAddress_PortValue:
343 if v == nil {
344 err := SocketAddressValidationError{
345 field: "PortSpecifier",
346 reason: "oneof value cannot be a typed-nil",
347 }
348 if !all {
349 return err
350 }
351 errors = append(errors, err)
352 }
353 oneofPortSpecifierPresent = true
354
355 if m.GetPortValue() > 65535 {
356 err := SocketAddressValidationError{
357 field: "PortValue",
358 reason: "value must be less than or equal to 65535",
359 }
360 if !all {
361 return err
362 }
363 errors = append(errors, err)
364 }
365
366 case *SocketAddress_NamedPort:
367 if v == nil {
368 err := SocketAddressValidationError{
369 field: "PortSpecifier",
370 reason: "oneof value cannot be a typed-nil",
371 }
372 if !all {
373 return err
374 }
375 errors = append(errors, err)
376 }
377 oneofPortSpecifierPresent = true
378 // no validation rules for NamedPort
379 default:
380 _ = v // ensures v is used
381 }
382 if !oneofPortSpecifierPresent {
383 err := SocketAddressValidationError{
384 field: "PortSpecifier",
385 reason: "value is required",
386 }
387 if !all {
388 return err
389 }
390 errors = append(errors, err)
391 }
392
393 if len(errors) > 0 {
394 return SocketAddressMultiError(errors)
395 }
396
397 return nil
398 }
399
400 // SocketAddressMultiError is an error wrapping multiple validation errors
401 // returned by SocketAddress.ValidateAll() if the designated constraints
402 // aren't met.
403 type SocketAddressMultiError []error
404
405 // Error returns a concatenation of all the error messages it wraps.
406 func (m SocketAddressMultiError) Error() string {
407 var msgs []string
408 for _, err := range m {
409 msgs = append(msgs, err.Error())
410 }
411 return strings.Join(msgs, "; ")
412 }
413
414 // AllErrors returns a list of validation violation errors.
415 func (m SocketAddressMultiError) AllErrors() []error { return m }
416
417 // SocketAddressValidationError is the validation error returned by
418 // SocketAddress.Validate if the designated constraints aren't met.
419 type SocketAddressValidationError struct {
420 field string
421 reason string
422 cause error
423 key bool
424 }
425
426 // Field function returns field value.
427 func (e SocketAddressValidationError) Field() string { return e.field }
428
429 // Reason function returns reason value.
430 func (e SocketAddressValidationError) Reason() string { return e.reason }
431
432 // Cause function returns cause value.
433 func (e SocketAddressValidationError) Cause() error { return e.cause }
434
435 // Key function returns key value.
436 func (e SocketAddressValidationError) Key() bool { return e.key }
437
438 // ErrorName returns error name.
439 func (e SocketAddressValidationError) ErrorName() string { return "SocketAddressValidationError" }
440
441 // Error satisfies the builtin error interface
442 func (e SocketAddressValidationError) Error() string {
443 cause := ""
444 if e.cause != nil {
445 cause = fmt.Sprintf(" | caused by: %v", e.cause)
446 }
447
448 key := ""
449 if e.key {
450 key = "key for "
451 }
452
453 return fmt.Sprintf(
454 "invalid %sSocketAddress.%s: %s%s",
455 key,
456 e.field,
457 e.reason,
458 cause)
459 }
460
461 var _ error = SocketAddressValidationError{}
462
463 var _ interface {
464 Field() string
465 Reason() string
466 Key() bool
467 Cause() error
468 ErrorName() string
469 } = SocketAddressValidationError{}
470
471 // Validate checks the field values on TcpKeepalive with the rules defined in
472 // the proto definition for this message. If any rules are violated, the first
473 // error encountered is returned, or nil if there are no violations.
474 func (m *TcpKeepalive) Validate() error {
475 return m.validate(false)
476 }
477
478 // ValidateAll checks the field values on TcpKeepalive with the rules defined
479 // in the proto definition for this message. If any rules are violated, the
480 // result is a list of violation errors wrapped in TcpKeepaliveMultiError, or
481 // nil if none found.
482 func (m *TcpKeepalive) ValidateAll() error {
483 return m.validate(true)
484 }
485
486 func (m *TcpKeepalive) validate(all bool) error {
487 if m == nil {
488 return nil
489 }
490
491 var errors []error
492
493 if all {
494 switch v := interface{}(m.GetKeepaliveProbes()).(type) {
495 case interface{ ValidateAll() error }:
496 if err := v.ValidateAll(); err != nil {
497 errors = append(errors, TcpKeepaliveValidationError{
498 field: "KeepaliveProbes",
499 reason: "embedded message failed validation",
500 cause: err,
501 })
502 }
503 case interface{ Validate() error }:
504 if err := v.Validate(); err != nil {
505 errors = append(errors, TcpKeepaliveValidationError{
506 field: "KeepaliveProbes",
507 reason: "embedded message failed validation",
508 cause: err,
509 })
510 }
511 }
512 } else if v, ok := interface{}(m.GetKeepaliveProbes()).(interface{ Validate() error }); ok {
513 if err := v.Validate(); err != nil {
514 return TcpKeepaliveValidationError{
515 field: "KeepaliveProbes",
516 reason: "embedded message failed validation",
517 cause: err,
518 }
519 }
520 }
521
522 if all {
523 switch v := interface{}(m.GetKeepaliveTime()).(type) {
524 case interface{ ValidateAll() error }:
525 if err := v.ValidateAll(); err != nil {
526 errors = append(errors, TcpKeepaliveValidationError{
527 field: "KeepaliveTime",
528 reason: "embedded message failed validation",
529 cause: err,
530 })
531 }
532 case interface{ Validate() error }:
533 if err := v.Validate(); err != nil {
534 errors = append(errors, TcpKeepaliveValidationError{
535 field: "KeepaliveTime",
536 reason: "embedded message failed validation",
537 cause: err,
538 })
539 }
540 }
541 } else if v, ok := interface{}(m.GetKeepaliveTime()).(interface{ Validate() error }); ok {
542 if err := v.Validate(); err != nil {
543 return TcpKeepaliveValidationError{
544 field: "KeepaliveTime",
545 reason: "embedded message failed validation",
546 cause: err,
547 }
548 }
549 }
550
551 if all {
552 switch v := interface{}(m.GetKeepaliveInterval()).(type) {
553 case interface{ ValidateAll() error }:
554 if err := v.ValidateAll(); err != nil {
555 errors = append(errors, TcpKeepaliveValidationError{
556 field: "KeepaliveInterval",
557 reason: "embedded message failed validation",
558 cause: err,
559 })
560 }
561 case interface{ Validate() error }:
562 if err := v.Validate(); err != nil {
563 errors = append(errors, TcpKeepaliveValidationError{
564 field: "KeepaliveInterval",
565 reason: "embedded message failed validation",
566 cause: err,
567 })
568 }
569 }
570 } else if v, ok := interface{}(m.GetKeepaliveInterval()).(interface{ Validate() error }); ok {
571 if err := v.Validate(); err != nil {
572 return TcpKeepaliveValidationError{
573 field: "KeepaliveInterval",
574 reason: "embedded message failed validation",
575 cause: err,
576 }
577 }
578 }
579
580 if len(errors) > 0 {
581 return TcpKeepaliveMultiError(errors)
582 }
583
584 return nil
585 }
586
587 // TcpKeepaliveMultiError is an error wrapping multiple validation errors
588 // returned by TcpKeepalive.ValidateAll() if the designated constraints aren't met.
589 type TcpKeepaliveMultiError []error
590
591 // Error returns a concatenation of all the error messages it wraps.
592 func (m TcpKeepaliveMultiError) Error() string {
593 var msgs []string
594 for _, err := range m {
595 msgs = append(msgs, err.Error())
596 }
597 return strings.Join(msgs, "; ")
598 }
599
600 // AllErrors returns a list of validation violation errors.
601 func (m TcpKeepaliveMultiError) AllErrors() []error { return m }
602
603 // TcpKeepaliveValidationError is the validation error returned by
604 // TcpKeepalive.Validate if the designated constraints aren't met.
605 type TcpKeepaliveValidationError struct {
606 field string
607 reason string
608 cause error
609 key bool
610 }
611
612 // Field function returns field value.
613 func (e TcpKeepaliveValidationError) Field() string { return e.field }
614
615 // Reason function returns reason value.
616 func (e TcpKeepaliveValidationError) Reason() string { return e.reason }
617
618 // Cause function returns cause value.
619 func (e TcpKeepaliveValidationError) Cause() error { return e.cause }
620
621 // Key function returns key value.
622 func (e TcpKeepaliveValidationError) Key() bool { return e.key }
623
624 // ErrorName returns error name.
625 func (e TcpKeepaliveValidationError) ErrorName() string { return "TcpKeepaliveValidationError" }
626
627 // Error satisfies the builtin error interface
628 func (e TcpKeepaliveValidationError) Error() string {
629 cause := ""
630 if e.cause != nil {
631 cause = fmt.Sprintf(" | caused by: %v", e.cause)
632 }
633
634 key := ""
635 if e.key {
636 key = "key for "
637 }
638
639 return fmt.Sprintf(
640 "invalid %sTcpKeepalive.%s: %s%s",
641 key,
642 e.field,
643 e.reason,
644 cause)
645 }
646
647 var _ error = TcpKeepaliveValidationError{}
648
649 var _ interface {
650 Field() string
651 Reason() string
652 Key() bool
653 Cause() error
654 ErrorName() string
655 } = TcpKeepaliveValidationError{}
656
657 // Validate checks the field values on ExtraSourceAddress with the rules
658 // defined in the proto definition for this message. If any rules are
659 // violated, the first error encountered is returned, or nil if there are no violations.
660 func (m *ExtraSourceAddress) Validate() error {
661 return m.validate(false)
662 }
663
664 // ValidateAll checks the field values on ExtraSourceAddress with the rules
665 // defined in the proto definition for this message. If any rules are
666 // violated, the result is a list of violation errors wrapped in
667 // ExtraSourceAddressMultiError, or nil if none found.
668 func (m *ExtraSourceAddress) ValidateAll() error {
669 return m.validate(true)
670 }
671
672 func (m *ExtraSourceAddress) validate(all bool) error {
673 if m == nil {
674 return nil
675 }
676
677 var errors []error
678
679 if m.GetAddress() == nil {
680 err := ExtraSourceAddressValidationError{
681 field: "Address",
682 reason: "value is required",
683 }
684 if !all {
685 return err
686 }
687 errors = append(errors, err)
688 }
689
690 if all {
691 switch v := interface{}(m.GetAddress()).(type) {
692 case interface{ ValidateAll() error }:
693 if err := v.ValidateAll(); err != nil {
694 errors = append(errors, ExtraSourceAddressValidationError{
695 field: "Address",
696 reason: "embedded message failed validation",
697 cause: err,
698 })
699 }
700 case interface{ Validate() error }:
701 if err := v.Validate(); err != nil {
702 errors = append(errors, ExtraSourceAddressValidationError{
703 field: "Address",
704 reason: "embedded message failed validation",
705 cause: err,
706 })
707 }
708 }
709 } else if v, ok := interface{}(m.GetAddress()).(interface{ Validate() error }); ok {
710 if err := v.Validate(); err != nil {
711 return ExtraSourceAddressValidationError{
712 field: "Address",
713 reason: "embedded message failed validation",
714 cause: err,
715 }
716 }
717 }
718
719 if all {
720 switch v := interface{}(m.GetSocketOptions()).(type) {
721 case interface{ ValidateAll() error }:
722 if err := v.ValidateAll(); err != nil {
723 errors = append(errors, ExtraSourceAddressValidationError{
724 field: "SocketOptions",
725 reason: "embedded message failed validation",
726 cause: err,
727 })
728 }
729 case interface{ Validate() error }:
730 if err := v.Validate(); err != nil {
731 errors = append(errors, ExtraSourceAddressValidationError{
732 field: "SocketOptions",
733 reason: "embedded message failed validation",
734 cause: err,
735 })
736 }
737 }
738 } else if v, ok := interface{}(m.GetSocketOptions()).(interface{ Validate() error }); ok {
739 if err := v.Validate(); err != nil {
740 return ExtraSourceAddressValidationError{
741 field: "SocketOptions",
742 reason: "embedded message failed validation",
743 cause: err,
744 }
745 }
746 }
747
748 if len(errors) > 0 {
749 return ExtraSourceAddressMultiError(errors)
750 }
751
752 return nil
753 }
754
755 // ExtraSourceAddressMultiError is an error wrapping multiple validation errors
756 // returned by ExtraSourceAddress.ValidateAll() if the designated constraints
757 // aren't met.
758 type ExtraSourceAddressMultiError []error
759
760 // Error returns a concatenation of all the error messages it wraps.
761 func (m ExtraSourceAddressMultiError) Error() string {
762 var msgs []string
763 for _, err := range m {
764 msgs = append(msgs, err.Error())
765 }
766 return strings.Join(msgs, "; ")
767 }
768
769 // AllErrors returns a list of validation violation errors.
770 func (m ExtraSourceAddressMultiError) AllErrors() []error { return m }
771
772 // ExtraSourceAddressValidationError is the validation error returned by
773 // ExtraSourceAddress.Validate if the designated constraints aren't met.
774 type ExtraSourceAddressValidationError struct {
775 field string
776 reason string
777 cause error
778 key bool
779 }
780
781 // Field function returns field value.
782 func (e ExtraSourceAddressValidationError) Field() string { return e.field }
783
784 // Reason function returns reason value.
785 func (e ExtraSourceAddressValidationError) Reason() string { return e.reason }
786
787 // Cause function returns cause value.
788 func (e ExtraSourceAddressValidationError) Cause() error { return e.cause }
789
790 // Key function returns key value.
791 func (e ExtraSourceAddressValidationError) Key() bool { return e.key }
792
793 // ErrorName returns error name.
794 func (e ExtraSourceAddressValidationError) ErrorName() string {
795 return "ExtraSourceAddressValidationError"
796 }
797
798 // Error satisfies the builtin error interface
799 func (e ExtraSourceAddressValidationError) Error() string {
800 cause := ""
801 if e.cause != nil {
802 cause = fmt.Sprintf(" | caused by: %v", e.cause)
803 }
804
805 key := ""
806 if e.key {
807 key = "key for "
808 }
809
810 return fmt.Sprintf(
811 "invalid %sExtraSourceAddress.%s: %s%s",
812 key,
813 e.field,
814 e.reason,
815 cause)
816 }
817
818 var _ error = ExtraSourceAddressValidationError{}
819
820 var _ interface {
821 Field() string
822 Reason() string
823 Key() bool
824 Cause() error
825 ErrorName() string
826 } = ExtraSourceAddressValidationError{}
827
828 // Validate checks the field values on BindConfig with the rules defined in the
829 // proto definition for this message. If any rules are violated, the first
830 // error encountered is returned, or nil if there are no violations.
831 func (m *BindConfig) Validate() error {
832 return m.validate(false)
833 }
834
835 // ValidateAll checks the field values on BindConfig with the rules defined in
836 // the proto definition for this message. If any rules are violated, the
837 // result is a list of violation errors wrapped in BindConfigMultiError, or
838 // nil if none found.
839 func (m *BindConfig) ValidateAll() error {
840 return m.validate(true)
841 }
842
843 func (m *BindConfig) validate(all bool) error {
844 if m == nil {
845 return nil
846 }
847
848 var errors []error
849
850 if all {
851 switch v := interface{}(m.GetSourceAddress()).(type) {
852 case interface{ ValidateAll() error }:
853 if err := v.ValidateAll(); err != nil {
854 errors = append(errors, BindConfigValidationError{
855 field: "SourceAddress",
856 reason: "embedded message failed validation",
857 cause: err,
858 })
859 }
860 case interface{ Validate() error }:
861 if err := v.Validate(); err != nil {
862 errors = append(errors, BindConfigValidationError{
863 field: "SourceAddress",
864 reason: "embedded message failed validation",
865 cause: err,
866 })
867 }
868 }
869 } else if v, ok := interface{}(m.GetSourceAddress()).(interface{ Validate() error }); ok {
870 if err := v.Validate(); err != nil {
871 return BindConfigValidationError{
872 field: "SourceAddress",
873 reason: "embedded message failed validation",
874 cause: err,
875 }
876 }
877 }
878
879 if all {
880 switch v := interface{}(m.GetFreebind()).(type) {
881 case interface{ ValidateAll() error }:
882 if err := v.ValidateAll(); err != nil {
883 errors = append(errors, BindConfigValidationError{
884 field: "Freebind",
885 reason: "embedded message failed validation",
886 cause: err,
887 })
888 }
889 case interface{ Validate() error }:
890 if err := v.Validate(); err != nil {
891 errors = append(errors, BindConfigValidationError{
892 field: "Freebind",
893 reason: "embedded message failed validation",
894 cause: err,
895 })
896 }
897 }
898 } else if v, ok := interface{}(m.GetFreebind()).(interface{ Validate() error }); ok {
899 if err := v.Validate(); err != nil {
900 return BindConfigValidationError{
901 field: "Freebind",
902 reason: "embedded message failed validation",
903 cause: err,
904 }
905 }
906 }
907
908 for idx, item := range m.GetSocketOptions() {
909 _, _ = idx, item
910
911 if all {
912 switch v := interface{}(item).(type) {
913 case interface{ ValidateAll() error }:
914 if err := v.ValidateAll(); err != nil {
915 errors = append(errors, BindConfigValidationError{
916 field: fmt.Sprintf("SocketOptions[%v]", idx),
917 reason: "embedded message failed validation",
918 cause: err,
919 })
920 }
921 case interface{ Validate() error }:
922 if err := v.Validate(); err != nil {
923 errors = append(errors, BindConfigValidationError{
924 field: fmt.Sprintf("SocketOptions[%v]", idx),
925 reason: "embedded message failed validation",
926 cause: err,
927 })
928 }
929 }
930 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
931 if err := v.Validate(); err != nil {
932 return BindConfigValidationError{
933 field: fmt.Sprintf("SocketOptions[%v]", idx),
934 reason: "embedded message failed validation",
935 cause: err,
936 }
937 }
938 }
939
940 }
941
942 for idx, item := range m.GetExtraSourceAddresses() {
943 _, _ = idx, item
944
945 if all {
946 switch v := interface{}(item).(type) {
947 case interface{ ValidateAll() error }:
948 if err := v.ValidateAll(); err != nil {
949 errors = append(errors, BindConfigValidationError{
950 field: fmt.Sprintf("ExtraSourceAddresses[%v]", idx),
951 reason: "embedded message failed validation",
952 cause: err,
953 })
954 }
955 case interface{ Validate() error }:
956 if err := v.Validate(); err != nil {
957 errors = append(errors, BindConfigValidationError{
958 field: fmt.Sprintf("ExtraSourceAddresses[%v]", idx),
959 reason: "embedded message failed validation",
960 cause: err,
961 })
962 }
963 }
964 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
965 if err := v.Validate(); err != nil {
966 return BindConfigValidationError{
967 field: fmt.Sprintf("ExtraSourceAddresses[%v]", idx),
968 reason: "embedded message failed validation",
969 cause: err,
970 }
971 }
972 }
973
974 }
975
976 for idx, item := range m.GetAdditionalSourceAddresses() {
977 _, _ = idx, item
978
979 if all {
980 switch v := interface{}(item).(type) {
981 case interface{ ValidateAll() error }:
982 if err := v.ValidateAll(); err != nil {
983 errors = append(errors, BindConfigValidationError{
984 field: fmt.Sprintf("AdditionalSourceAddresses[%v]", idx),
985 reason: "embedded message failed validation",
986 cause: err,
987 })
988 }
989 case interface{ Validate() error }:
990 if err := v.Validate(); err != nil {
991 errors = append(errors, BindConfigValidationError{
992 field: fmt.Sprintf("AdditionalSourceAddresses[%v]", idx),
993 reason: "embedded message failed validation",
994 cause: err,
995 })
996 }
997 }
998 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
999 if err := v.Validate(); err != nil {
1000 return BindConfigValidationError{
1001 field: fmt.Sprintf("AdditionalSourceAddresses[%v]", idx),
1002 reason: "embedded message failed validation",
1003 cause: err,
1004 }
1005 }
1006 }
1007
1008 }
1009
1010 if all {
1011 switch v := interface{}(m.GetLocalAddressSelector()).(type) {
1012 case interface{ ValidateAll() error }:
1013 if err := v.ValidateAll(); err != nil {
1014 errors = append(errors, BindConfigValidationError{
1015 field: "LocalAddressSelector",
1016 reason: "embedded message failed validation",
1017 cause: err,
1018 })
1019 }
1020 case interface{ Validate() error }:
1021 if err := v.Validate(); err != nil {
1022 errors = append(errors, BindConfigValidationError{
1023 field: "LocalAddressSelector",
1024 reason: "embedded message failed validation",
1025 cause: err,
1026 })
1027 }
1028 }
1029 } else if v, ok := interface{}(m.GetLocalAddressSelector()).(interface{ Validate() error }); ok {
1030 if err := v.Validate(); err != nil {
1031 return BindConfigValidationError{
1032 field: "LocalAddressSelector",
1033 reason: "embedded message failed validation",
1034 cause: err,
1035 }
1036 }
1037 }
1038
1039 if len(errors) > 0 {
1040 return BindConfigMultiError(errors)
1041 }
1042
1043 return nil
1044 }
1045
1046 // BindConfigMultiError is an error wrapping multiple validation errors
1047 // returned by BindConfig.ValidateAll() if the designated constraints aren't met.
1048 type BindConfigMultiError []error
1049
1050 // Error returns a concatenation of all the error messages it wraps.
1051 func (m BindConfigMultiError) Error() string {
1052 var msgs []string
1053 for _, err := range m {
1054 msgs = append(msgs, err.Error())
1055 }
1056 return strings.Join(msgs, "; ")
1057 }
1058
1059 // AllErrors returns a list of validation violation errors.
1060 func (m BindConfigMultiError) AllErrors() []error { return m }
1061
1062 // BindConfigValidationError is the validation error returned by
1063 // BindConfig.Validate if the designated constraints aren't met.
1064 type BindConfigValidationError struct {
1065 field string
1066 reason string
1067 cause error
1068 key bool
1069 }
1070
1071 // Field function returns field value.
1072 func (e BindConfigValidationError) Field() string { return e.field }
1073
1074 // Reason function returns reason value.
1075 func (e BindConfigValidationError) Reason() string { return e.reason }
1076
1077 // Cause function returns cause value.
1078 func (e BindConfigValidationError) Cause() error { return e.cause }
1079
1080 // Key function returns key value.
1081 func (e BindConfigValidationError) Key() bool { return e.key }
1082
1083 // ErrorName returns error name.
1084 func (e BindConfigValidationError) ErrorName() string { return "BindConfigValidationError" }
1085
1086 // Error satisfies the builtin error interface
1087 func (e BindConfigValidationError) Error() string {
1088 cause := ""
1089 if e.cause != nil {
1090 cause = fmt.Sprintf(" | caused by: %v", e.cause)
1091 }
1092
1093 key := ""
1094 if e.key {
1095 key = "key for "
1096 }
1097
1098 return fmt.Sprintf(
1099 "invalid %sBindConfig.%s: %s%s",
1100 key,
1101 e.field,
1102 e.reason,
1103 cause)
1104 }
1105
1106 var _ error = BindConfigValidationError{}
1107
1108 var _ interface {
1109 Field() string
1110 Reason() string
1111 Key() bool
1112 Cause() error
1113 ErrorName() string
1114 } = BindConfigValidationError{}
1115
1116 // Validate checks the field values on Address with the rules defined in the
1117 // proto definition for this message. If any rules are violated, the first
1118 // error encountered is returned, or nil if there are no violations.
1119 func (m *Address) Validate() error {
1120 return m.validate(false)
1121 }
1122
1123 // ValidateAll checks the field values on Address with the rules defined in the
1124 // proto definition for this message. If any rules are violated, the result is
1125 // a list of violation errors wrapped in AddressMultiError, or nil if none found.
1126 func (m *Address) ValidateAll() error {
1127 return m.validate(true)
1128 }
1129
1130 func (m *Address) validate(all bool) error {
1131 if m == nil {
1132 return nil
1133 }
1134
1135 var errors []error
1136
1137 oneofAddressPresent := false
1138 switch v := m.Address.(type) {
1139 case *Address_SocketAddress:
1140 if v == nil {
1141 err := AddressValidationError{
1142 field: "Address",
1143 reason: "oneof value cannot be a typed-nil",
1144 }
1145 if !all {
1146 return err
1147 }
1148 errors = append(errors, err)
1149 }
1150 oneofAddressPresent = true
1151
1152 if all {
1153 switch v := interface{}(m.GetSocketAddress()).(type) {
1154 case interface{ ValidateAll() error }:
1155 if err := v.ValidateAll(); err != nil {
1156 errors = append(errors, AddressValidationError{
1157 field: "SocketAddress",
1158 reason: "embedded message failed validation",
1159 cause: err,
1160 })
1161 }
1162 case interface{ Validate() error }:
1163 if err := v.Validate(); err != nil {
1164 errors = append(errors, AddressValidationError{
1165 field: "SocketAddress",
1166 reason: "embedded message failed validation",
1167 cause: err,
1168 })
1169 }
1170 }
1171 } else if v, ok := interface{}(m.GetSocketAddress()).(interface{ Validate() error }); ok {
1172 if err := v.Validate(); err != nil {
1173 return AddressValidationError{
1174 field: "SocketAddress",
1175 reason: "embedded message failed validation",
1176 cause: err,
1177 }
1178 }
1179 }
1180
1181 case *Address_Pipe:
1182 if v == nil {
1183 err := AddressValidationError{
1184 field: "Address",
1185 reason: "oneof value cannot be a typed-nil",
1186 }
1187 if !all {
1188 return err
1189 }
1190 errors = append(errors, err)
1191 }
1192 oneofAddressPresent = true
1193
1194 if all {
1195 switch v := interface{}(m.GetPipe()).(type) {
1196 case interface{ ValidateAll() error }:
1197 if err := v.ValidateAll(); err != nil {
1198 errors = append(errors, AddressValidationError{
1199 field: "Pipe",
1200 reason: "embedded message failed validation",
1201 cause: err,
1202 })
1203 }
1204 case interface{ Validate() error }:
1205 if err := v.Validate(); err != nil {
1206 errors = append(errors, AddressValidationError{
1207 field: "Pipe",
1208 reason: "embedded message failed validation",
1209 cause: err,
1210 })
1211 }
1212 }
1213 } else if v, ok := interface{}(m.GetPipe()).(interface{ Validate() error }); ok {
1214 if err := v.Validate(); err != nil {
1215 return AddressValidationError{
1216 field: "Pipe",
1217 reason: "embedded message failed validation",
1218 cause: err,
1219 }
1220 }
1221 }
1222
1223 case *Address_EnvoyInternalAddress:
1224 if v == nil {
1225 err := AddressValidationError{
1226 field: "Address",
1227 reason: "oneof value cannot be a typed-nil",
1228 }
1229 if !all {
1230 return err
1231 }
1232 errors = append(errors, err)
1233 }
1234 oneofAddressPresent = true
1235
1236 if all {
1237 switch v := interface{}(m.GetEnvoyInternalAddress()).(type) {
1238 case interface{ ValidateAll() error }:
1239 if err := v.ValidateAll(); err != nil {
1240 errors = append(errors, AddressValidationError{
1241 field: "EnvoyInternalAddress",
1242 reason: "embedded message failed validation",
1243 cause: err,
1244 })
1245 }
1246 case interface{ Validate() error }:
1247 if err := v.Validate(); err != nil {
1248 errors = append(errors, AddressValidationError{
1249 field: "EnvoyInternalAddress",
1250 reason: "embedded message failed validation",
1251 cause: err,
1252 })
1253 }
1254 }
1255 } else if v, ok := interface{}(m.GetEnvoyInternalAddress()).(interface{ Validate() error }); ok {
1256 if err := v.Validate(); err != nil {
1257 return AddressValidationError{
1258 field: "EnvoyInternalAddress",
1259 reason: "embedded message failed validation",
1260 cause: err,
1261 }
1262 }
1263 }
1264
1265 default:
1266 _ = v // ensures v is used
1267 }
1268 if !oneofAddressPresent {
1269 err := AddressValidationError{
1270 field: "Address",
1271 reason: "value is required",
1272 }
1273 if !all {
1274 return err
1275 }
1276 errors = append(errors, err)
1277 }
1278
1279 if len(errors) > 0 {
1280 return AddressMultiError(errors)
1281 }
1282
1283 return nil
1284 }
1285
1286 // AddressMultiError is an error wrapping multiple validation errors returned
1287 // by Address.ValidateAll() if the designated constraints aren't met.
1288 type AddressMultiError []error
1289
1290 // Error returns a concatenation of all the error messages it wraps.
1291 func (m AddressMultiError) Error() string {
1292 var msgs []string
1293 for _, err := range m {
1294 msgs = append(msgs, err.Error())
1295 }
1296 return strings.Join(msgs, "; ")
1297 }
1298
1299 // AllErrors returns a list of validation violation errors.
1300 func (m AddressMultiError) AllErrors() []error { return m }
1301
1302 // AddressValidationError is the validation error returned by Address.Validate
1303 // if the designated constraints aren't met.
1304 type AddressValidationError struct {
1305 field string
1306 reason string
1307 cause error
1308 key bool
1309 }
1310
1311 // Field function returns field value.
1312 func (e AddressValidationError) Field() string { return e.field }
1313
1314 // Reason function returns reason value.
1315 func (e AddressValidationError) Reason() string { return e.reason }
1316
1317 // Cause function returns cause value.
1318 func (e AddressValidationError) Cause() error { return e.cause }
1319
1320 // Key function returns key value.
1321 func (e AddressValidationError) Key() bool { return e.key }
1322
1323 // ErrorName returns error name.
1324 func (e AddressValidationError) ErrorName() string { return "AddressValidationError" }
1325
1326 // Error satisfies the builtin error interface
1327 func (e AddressValidationError) Error() string {
1328 cause := ""
1329 if e.cause != nil {
1330 cause = fmt.Sprintf(" | caused by: %v", e.cause)
1331 }
1332
1333 key := ""
1334 if e.key {
1335 key = "key for "
1336 }
1337
1338 return fmt.Sprintf(
1339 "invalid %sAddress.%s: %s%s",
1340 key,
1341 e.field,
1342 e.reason,
1343 cause)
1344 }
1345
1346 var _ error = AddressValidationError{}
1347
1348 var _ interface {
1349 Field() string
1350 Reason() string
1351 Key() bool
1352 Cause() error
1353 ErrorName() string
1354 } = AddressValidationError{}
1355
1356 // Validate checks the field values on CidrRange with the rules defined in the
1357 // proto definition for this message. If any rules are violated, the first
1358 // error encountered is returned, or nil if there are no violations.
1359 func (m *CidrRange) Validate() error {
1360 return m.validate(false)
1361 }
1362
1363 // ValidateAll checks the field values on CidrRange with the rules defined in
1364 // the proto definition for this message. If any rules are violated, the
1365 // result is a list of violation errors wrapped in CidrRangeMultiError, or nil
1366 // if none found.
1367 func (m *CidrRange) ValidateAll() error {
1368 return m.validate(true)
1369 }
1370
1371 func (m *CidrRange) validate(all bool) error {
1372 if m == nil {
1373 return nil
1374 }
1375
1376 var errors []error
1377
1378 if utf8.RuneCountInString(m.GetAddressPrefix()) < 1 {
1379 err := CidrRangeValidationError{
1380 field: "AddressPrefix",
1381 reason: "value length must be at least 1 runes",
1382 }
1383 if !all {
1384 return err
1385 }
1386 errors = append(errors, err)
1387 }
1388
1389 if wrapper := m.GetPrefixLen(); wrapper != nil {
1390
1391 if wrapper.GetValue() > 128 {
1392 err := CidrRangeValidationError{
1393 field: "PrefixLen",
1394 reason: "value must be less than or equal to 128",
1395 }
1396 if !all {
1397 return err
1398 }
1399 errors = append(errors, err)
1400 }
1401
1402 }
1403
1404 if len(errors) > 0 {
1405 return CidrRangeMultiError(errors)
1406 }
1407
1408 return nil
1409 }
1410
1411 // CidrRangeMultiError is an error wrapping multiple validation errors returned
1412 // by CidrRange.ValidateAll() if the designated constraints aren't met.
1413 type CidrRangeMultiError []error
1414
1415 // Error returns a concatenation of all the error messages it wraps.
1416 func (m CidrRangeMultiError) Error() string {
1417 var msgs []string
1418 for _, err := range m {
1419 msgs = append(msgs, err.Error())
1420 }
1421 return strings.Join(msgs, "; ")
1422 }
1423
1424 // AllErrors returns a list of validation violation errors.
1425 func (m CidrRangeMultiError) AllErrors() []error { return m }
1426
1427 // CidrRangeValidationError is the validation error returned by
1428 // CidrRange.Validate if the designated constraints aren't met.
1429 type CidrRangeValidationError struct {
1430 field string
1431 reason string
1432 cause error
1433 key bool
1434 }
1435
1436 // Field function returns field value.
1437 func (e CidrRangeValidationError) Field() string { return e.field }
1438
1439 // Reason function returns reason value.
1440 func (e CidrRangeValidationError) Reason() string { return e.reason }
1441
1442 // Cause function returns cause value.
1443 func (e CidrRangeValidationError) Cause() error { return e.cause }
1444
1445 // Key function returns key value.
1446 func (e CidrRangeValidationError) Key() bool { return e.key }
1447
1448 // ErrorName returns error name.
1449 func (e CidrRangeValidationError) ErrorName() string { return "CidrRangeValidationError" }
1450
1451 // Error satisfies the builtin error interface
1452 func (e CidrRangeValidationError) Error() string {
1453 cause := ""
1454 if e.cause != nil {
1455 cause = fmt.Sprintf(" | caused by: %v", e.cause)
1456 }
1457
1458 key := ""
1459 if e.key {
1460 key = "key for "
1461 }
1462
1463 return fmt.Sprintf(
1464 "invalid %sCidrRange.%s: %s%s",
1465 key,
1466 e.field,
1467 e.reason,
1468 cause)
1469 }
1470
1471 var _ error = CidrRangeValidationError{}
1472
1473 var _ interface {
1474 Field() string
1475 Reason() string
1476 Key() bool
1477 Cause() error
1478 ErrorName() string
1479 } = CidrRangeValidationError{}