Debian Codegraph @

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