Debian Codegraph @

envoy/config/metrics/v2/stats.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/metrics/v2/stats.proto
4
5 package metricsv2
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 StatsSink with the rules defined in the
40 // 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 *StatsSink) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on StatsSink with the rules defined in
47 // the proto definition for this message. If any rules are violated, the
48 // result is a list of violation errors wrapped in StatsSinkMultiError, or nil
49 // if none found.
50 func (m *StatsSink) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *StatsSink) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 // no validation rules for Name
62
63 switch v := m.ConfigType.(type) {
64 case *StatsSink_Config:
65 if v == nil {
66 err := StatsSinkValidationError{
67 field: "ConfigType",
68 reason: "oneof value cannot be a typed-nil",
69 }
70 if !all {
71 return err
72 }
73 errors = append(errors, err)
74 }
75
76 if all {
77 switch v := interface{}(m.GetConfig()).(type) {
78 case interface{ ValidateAll() error }:
79 if err := v.ValidateAll(); err != nil {
80 errors = append(errors, StatsSinkValidationError{
81 field: "Config",
82 reason: "embedded message failed validation",
83 cause: err,
84 })
85 }
86 case interface{ Validate() error }:
87 if err := v.Validate(); err != nil {
88 errors = append(errors, StatsSinkValidationError{
89 field: "Config",
90 reason: "embedded message failed validation",
91 cause: err,
92 })
93 }
94 }
95 } else if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok {
96 if err := v.Validate(); err != nil {
97 return StatsSinkValidationError{
98 field: "Config",
99 reason: "embedded message failed validation",
100 cause: err,
101 }
102 }
103 }
104
105 case *StatsSink_TypedConfig:
106 if v == nil {
107 err := StatsSinkValidationError{
108 field: "ConfigType",
109 reason: "oneof value cannot be a typed-nil",
110 }
111 if !all {
112 return err
113 }
114 errors = append(errors, err)
115 }
116
117 if all {
118 switch v := interface{}(m.GetTypedConfig()).(type) {
119 case interface{ ValidateAll() error }:
120 if err := v.ValidateAll(); err != nil {
121 errors = append(errors, StatsSinkValidationError{
122 field: "TypedConfig",
123 reason: "embedded message failed validation",
124 cause: err,
125 })
126 }
127 case interface{ Validate() error }:
128 if err := v.Validate(); err != nil {
129 errors = append(errors, StatsSinkValidationError{
130 field: "TypedConfig",
131 reason: "embedded message failed validation",
132 cause: err,
133 })
134 }
135 }
136 } else if v, ok := interface{}(m.GetTypedConfig()).(interface{ Validate() error }); ok {
137 if err := v.Validate(); err != nil {
138 return StatsSinkValidationError{
139 field: "TypedConfig",
140 reason: "embedded message failed validation",
141 cause: err,
142 }
143 }
144 }
145
146 default:
147 _ = v // ensures v is used
148 }
149
150 if len(errors) > 0 {
151 return StatsSinkMultiError(errors)
152 }
153
154 return nil
155 }
156
157 // StatsSinkMultiError is an error wrapping multiple validation errors returned
158 // by StatsSink.ValidateAll() if the designated constraints aren't met.
159 type StatsSinkMultiError []error
160
161 // Error returns a concatenation of all the error messages it wraps.
162 func (m StatsSinkMultiError) Error() string {
163 var msgs []string
164 for _, err := range m {
165 msgs = append(msgs, err.Error())
166 }
167 return strings.Join(msgs, "; ")
168 }
169
170 // AllErrors returns a list of validation violation errors.
171 func (m StatsSinkMultiError) AllErrors() []error { return m }
172
173 // StatsSinkValidationError is the validation error returned by
174 // StatsSink.Validate if the designated constraints aren't met.
175 type StatsSinkValidationError struct {
176 field string
177 reason string
178 cause error
179 key bool
180 }
181
182 // Field function returns field value.
183 func (e StatsSinkValidationError) Field() string { return e.field }
184
185 // Reason function returns reason value.
186 func (e StatsSinkValidationError) Reason() string { return e.reason }
187
188 // Cause function returns cause value.
189 func (e StatsSinkValidationError) Cause() error { return e.cause }
190
191 // Key function returns key value.
192 func (e StatsSinkValidationError) Key() bool { return e.key }
193
194 // ErrorName returns error name.
195 func (e StatsSinkValidationError) ErrorName() string { return "StatsSinkValidationError" }
196
197 // Error satisfies the builtin error interface
198 func (e StatsSinkValidationError) Error() string {
199 cause := ""
200 if e.cause != nil {
201 cause = fmt.Sprintf(" | caused by: %v", e.cause)
202 }
203
204 key := ""
205 if e.key {
206 key = "key for "
207 }
208
209 return fmt.Sprintf(
210 "invalid %sStatsSink.%s: %s%s",
211 key,
212 e.field,
213 e.reason,
214 cause)
215 }
216
217 var _ error = StatsSinkValidationError{}
218
219 var _ interface {
220 Field() string
221 Reason() string
222 Key() bool
223 Cause() error
224 ErrorName() string
225 } = StatsSinkValidationError{}
226
227 // Validate checks the field values on StatsConfig with the rules defined in
228 // the proto definition for this message. If any rules are violated, the first
229 // error encountered is returned, or nil if there are no violations.
230 func (m *StatsConfig) Validate() error {
231 return m.validate(false)
232 }
233
234 // ValidateAll checks the field values on StatsConfig with the rules defined in
235 // the proto definition for this message. If any rules are violated, the
236 // result is a list of violation errors wrapped in StatsConfigMultiError, or
237 // nil if none found.
238 func (m *StatsConfig) ValidateAll() error {
239 return m.validate(true)
240 }
241
242 func (m *StatsConfig) validate(all bool) error {
243 if m == nil {
244 return nil
245 }
246
247 var errors []error
248
249 for idx, item := range m.GetStatsTags() {
250 _, _ = idx, item
251
252 if all {
253 switch v := interface{}(item).(type) {
254 case interface{ ValidateAll() error }:
255 if err := v.ValidateAll(); err != nil {
256 errors = append(errors, StatsConfigValidationError{
257 field: fmt.Sprintf("StatsTags[%v]", idx),
258 reason: "embedded message failed validation",
259 cause: err,
260 })
261 }
262 case interface{ Validate() error }:
263 if err := v.Validate(); err != nil {
264 errors = append(errors, StatsConfigValidationError{
265 field: fmt.Sprintf("StatsTags[%v]", idx),
266 reason: "embedded message failed validation",
267 cause: err,
268 })
269 }
270 }
271 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
272 if err := v.Validate(); err != nil {
273 return StatsConfigValidationError{
274 field: fmt.Sprintf("StatsTags[%v]", idx),
275 reason: "embedded message failed validation",
276 cause: err,
277 }
278 }
279 }
280
281 }
282
283 if all {
284 switch v := interface{}(m.GetUseAllDefaultTags()).(type) {
285 case interface{ ValidateAll() error }:
286 if err := v.ValidateAll(); err != nil {
287 errors = append(errors, StatsConfigValidationError{
288 field: "UseAllDefaultTags",
289 reason: "embedded message failed validation",
290 cause: err,
291 })
292 }
293 case interface{ Validate() error }:
294 if err := v.Validate(); err != nil {
295 errors = append(errors, StatsConfigValidationError{
296 field: "UseAllDefaultTags",
297 reason: "embedded message failed validation",
298 cause: err,
299 })
300 }
301 }
302 } else if v, ok := interface{}(m.GetUseAllDefaultTags()).(interface{ Validate() error }); ok {
303 if err := v.Validate(); err != nil {
304 return StatsConfigValidationError{
305 field: "UseAllDefaultTags",
306 reason: "embedded message failed validation",
307 cause: err,
308 }
309 }
310 }
311
312 if all {
313 switch v := interface{}(m.GetStatsMatcher()).(type) {
314 case interface{ ValidateAll() error }:
315 if err := v.ValidateAll(); err != nil {
316 errors = append(errors, StatsConfigValidationError{
317 field: "StatsMatcher",
318 reason: "embedded message failed validation",
319 cause: err,
320 })
321 }
322 case interface{ Validate() error }:
323 if err := v.Validate(); err != nil {
324 errors = append(errors, StatsConfigValidationError{
325 field: "StatsMatcher",
326 reason: "embedded message failed validation",
327 cause: err,
328 })
329 }
330 }
331 } else if v, ok := interface{}(m.GetStatsMatcher()).(interface{ Validate() error }); ok {
332 if err := v.Validate(); err != nil {
333 return StatsConfigValidationError{
334 field: "StatsMatcher",
335 reason: "embedded message failed validation",
336 cause: err,
337 }
338 }
339 }
340
341 if len(errors) > 0 {
342 return StatsConfigMultiError(errors)
343 }
344
345 return nil
346 }
347
348 // StatsConfigMultiError is an error wrapping multiple validation errors
349 // returned by StatsConfig.ValidateAll() if the designated constraints aren't met.
350 type StatsConfigMultiError []error
351
352 // Error returns a concatenation of all the error messages it wraps.
353 func (m StatsConfigMultiError) Error() string {
354 var msgs []string
355 for _, err := range m {
356 msgs = append(msgs, err.Error())
357 }
358 return strings.Join(msgs, "; ")
359 }
360
361 // AllErrors returns a list of validation violation errors.
362 func (m StatsConfigMultiError) AllErrors() []error { return m }
363
364 // StatsConfigValidationError is the validation error returned by
365 // StatsConfig.Validate if the designated constraints aren't met.
366 type StatsConfigValidationError struct {
367 field string
368 reason string
369 cause error
370 key bool
371 }
372
373 // Field function returns field value.
374 func (e StatsConfigValidationError) Field() string { return e.field }
375
376 // Reason function returns reason value.
377 func (e StatsConfigValidationError) Reason() string { return e.reason }
378
379 // Cause function returns cause value.
380 func (e StatsConfigValidationError) Cause() error { return e.cause }
381
382 // Key function returns key value.
383 func (e StatsConfigValidationError) Key() bool { return e.key }
384
385 // ErrorName returns error name.
386 func (e StatsConfigValidationError) ErrorName() string { return "StatsConfigValidationError" }
387
388 // Error satisfies the builtin error interface
389 func (e StatsConfigValidationError) Error() string {
390 cause := ""
391 if e.cause != nil {
392 cause = fmt.Sprintf(" | caused by: %v", e.cause)
393 }
394
395 key := ""
396 if e.key {
397 key = "key for "
398 }
399
400 return fmt.Sprintf(
401 "invalid %sStatsConfig.%s: %s%s",
402 key,
403 e.field,
404 e.reason,
405 cause)
406 }
407
408 var _ error = StatsConfigValidationError{}
409
410 var _ interface {
411 Field() string
412 Reason() string
413 Key() bool
414 Cause() error
415 ErrorName() string
416 } = StatsConfigValidationError{}
417
418 // Validate checks the field values on StatsMatcher with the rules defined in
419 // the proto definition for this message. If any rules are violated, the first
420 // error encountered is returned, or nil if there are no violations.
421 func (m *StatsMatcher) Validate() error {
422 return m.validate(false)
423 }
424
425 // ValidateAll checks the field values on StatsMatcher with the rules defined
426 // in the proto definition for this message. If any rules are violated, the
427 // result is a list of violation errors wrapped in StatsMatcherMultiError, or
428 // nil if none found.
429 func (m *StatsMatcher) ValidateAll() error {
430 return m.validate(true)
431 }
432
433 func (m *StatsMatcher) validate(all bool) error {
434 if m == nil {
435 return nil
436 }
437
438 var errors []error
439
440 oneofStatsMatcherPresent := false
441 switch v := m.StatsMatcher.(type) {
442 case *StatsMatcher_RejectAll:
443 if v == nil {
444 err := StatsMatcherValidationError{
445 field: "StatsMatcher",
446 reason: "oneof value cannot be a typed-nil",
447 }
448 if !all {
449 return err
450 }
451 errors = append(errors, err)
452 }
453 oneofStatsMatcherPresent = true
454 // no validation rules for RejectAll
455 case *StatsMatcher_ExclusionList:
456 if v == nil {
457 err := StatsMatcherValidationError{
458 field: "StatsMatcher",
459 reason: "oneof value cannot be a typed-nil",
460 }
461 if !all {
462 return err
463 }
464 errors = append(errors, err)
465 }
466 oneofStatsMatcherPresent = true
467
468 if all {
469 switch v := interface{}(m.GetExclusionList()).(type) {
470 case interface{ ValidateAll() error }:
471 if err := v.ValidateAll(); err != nil {
472 errors = append(errors, StatsMatcherValidationError{
473 field: "ExclusionList",
474 reason: "embedded message failed validation",
475 cause: err,
476 })
477 }
478 case interface{ Validate() error }:
479 if err := v.Validate(); err != nil {
480 errors = append(errors, StatsMatcherValidationError{
481 field: "ExclusionList",
482 reason: "embedded message failed validation",
483 cause: err,
484 })
485 }
486 }
487 } else if v, ok := interface{}(m.GetExclusionList()).(interface{ Validate() error }); ok {
488 if err := v.Validate(); err != nil {
489 return StatsMatcherValidationError{
490 field: "ExclusionList",
491 reason: "embedded message failed validation",
492 cause: err,
493 }
494 }
495 }
496
497 case *StatsMatcher_InclusionList:
498 if v == nil {
499 err := StatsMatcherValidationError{
500 field: "StatsMatcher",
501 reason: "oneof value cannot be a typed-nil",
502 }
503 if !all {
504 return err
505 }
506 errors = append(errors, err)
507 }
508 oneofStatsMatcherPresent = true
509
510 if all {
511 switch v := interface{}(m.GetInclusionList()).(type) {
512 case interface{ ValidateAll() error }:
513 if err := v.ValidateAll(); err != nil {
514 errors = append(errors, StatsMatcherValidationError{
515 field: "InclusionList",
516 reason: "embedded message failed validation",
517 cause: err,
518 })
519 }
520 case interface{ Validate() error }:
521 if err := v.Validate(); err != nil {
522 errors = append(errors, StatsMatcherValidationError{
523 field: "InclusionList",
524 reason: "embedded message failed validation",
525 cause: err,
526 })
527 }
528 }
529 } else if v, ok := interface{}(m.GetInclusionList()).(interface{ Validate() error }); ok {
530 if err := v.Validate(); err != nil {
531 return StatsMatcherValidationError{
532 field: "InclusionList",
533 reason: "embedded message failed validation",
534 cause: err,
535 }
536 }
537 }
538
539 default:
540 _ = v // ensures v is used
541 }
542 if !oneofStatsMatcherPresent {
543 err := StatsMatcherValidationError{
544 field: "StatsMatcher",
545 reason: "value is required",
546 }
547 if !all {
548 return err
549 }
550 errors = append(errors, err)
551 }
552
553 if len(errors) > 0 {
554 return StatsMatcherMultiError(errors)
555 }
556
557 return nil
558 }
559
560 // StatsMatcherMultiError is an error wrapping multiple validation errors
561 // returned by StatsMatcher.ValidateAll() if the designated constraints aren't met.
562 type StatsMatcherMultiError []error
563
564 // Error returns a concatenation of all the error messages it wraps.
565 func (m StatsMatcherMultiError) Error() string {
566 var msgs []string
567 for _, err := range m {
568 msgs = append(msgs, err.Error())
569 }
570 return strings.Join(msgs, "; ")
571 }
572
573 // AllErrors returns a list of validation violation errors.
574 func (m StatsMatcherMultiError) AllErrors() []error { return m }
575
576 // StatsMatcherValidationError is the validation error returned by
577 // StatsMatcher.Validate if the designated constraints aren't met.
578 type StatsMatcherValidationError struct {
579 field string
580 reason string
581 cause error
582 key bool
583 }
584
585 // Field function returns field value.
586 func (e StatsMatcherValidationError) Field() string { return e.field }
587
588 // Reason function returns reason value.
589 func (e StatsMatcherValidationError) Reason() string { return e.reason }
590
591 // Cause function returns cause value.
592 func (e StatsMatcherValidationError) Cause() error { return e.cause }
593
594 // Key function returns key value.
595 func (e StatsMatcherValidationError) Key() bool { return e.key }
596
597 // ErrorName returns error name.
598 func (e StatsMatcherValidationError) ErrorName() string { return "StatsMatcherValidationError" }
599
600 // Error satisfies the builtin error interface
601 func (e StatsMatcherValidationError) 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 %sStatsMatcher.%s: %s%s",
614 key,
615 e.field,
616 e.reason,
617 cause)
618 }
619
620 var _ error = StatsMatcherValidationError{}
621
622 var _ interface {
623 Field() string
624 Reason() string
625 Key() bool
626 Cause() error
627 ErrorName() string
628 } = StatsMatcherValidationError{}
629
630 // Validate checks the field values on TagSpecifier with the rules defined in
631 // the proto definition for this message. If any rules are violated, the first
632 // error encountered is returned, or nil if there are no violations.
633 func (m *TagSpecifier) Validate() error {
634 return m.validate(false)
635 }
636
637 // ValidateAll checks the field values on TagSpecifier with the rules defined
638 // in the proto definition for this message. If any rules are violated, the
639 // result is a list of violation errors wrapped in TagSpecifierMultiError, or
640 // nil if none found.
641 func (m *TagSpecifier) ValidateAll() error {
642 return m.validate(true)
643 }
644
645 func (m *TagSpecifier) validate(all bool) error {
646 if m == nil {
647 return nil
648 }
649
650 var errors []error
651
652 // no validation rules for TagName
653
654 switch v := m.TagValue.(type) {
655 case *TagSpecifier_Regex:
656 if v == nil {
657 err := TagSpecifierValidationError{
658 field: "TagValue",
659 reason: "oneof value cannot be a typed-nil",
660 }
661 if !all {
662 return err
663 }
664 errors = append(errors, err)
665 }
666
667 if len(m.GetRegex()) > 1024 {
668 err := TagSpecifierValidationError{
669 field: "Regex",
670 reason: "value length must be at most 1024 bytes",
671 }
672 if !all {
673 return err
674 }
675 errors = append(errors, err)
676 }
677
678 case *TagSpecifier_FixedValue:
679 if v == nil {
680 err := TagSpecifierValidationError{
681 field: "TagValue",
682 reason: "oneof value cannot be a typed-nil",
683 }
684 if !all {
685 return err
686 }
687 errors = append(errors, err)
688 }
689 // no validation rules for FixedValue
690 default:
691 _ = v // ensures v is used
692 }
693
694 if len(errors) > 0 {
695 return TagSpecifierMultiError(errors)
696 }
697
698 return nil
699 }
700
701 // TagSpecifierMultiError is an error wrapping multiple validation errors
702 // returned by TagSpecifier.ValidateAll() if the designated constraints aren't met.
703 type TagSpecifierMultiError []error
704
705 // Error returns a concatenation of all the error messages it wraps.
706 func (m TagSpecifierMultiError) Error() string {
707 var msgs []string
708 for _, err := range m {
709 msgs = append(msgs, err.Error())
710 }
711 return strings.Join(msgs, "; ")
712 }
713
714 // AllErrors returns a list of validation violation errors.
715 func (m TagSpecifierMultiError) AllErrors() []error { return m }
716
717 // TagSpecifierValidationError is the validation error returned by
718 // TagSpecifier.Validate if the designated constraints aren't met.
719 type TagSpecifierValidationError struct {
720 field string
721 reason string
722 cause error
723 key bool
724 }
725
726 // Field function returns field value.
727 func (e TagSpecifierValidationError) Field() string { return e.field }
728
729 // Reason function returns reason value.
730 func (e TagSpecifierValidationError) Reason() string { return e.reason }
731
732 // Cause function returns cause value.
733 func (e TagSpecifierValidationError) Cause() error { return e.cause }
734
735 // Key function returns key value.
736 func (e TagSpecifierValidationError) Key() bool { return e.key }
737
738 // ErrorName returns error name.
739 func (e TagSpecifierValidationError) ErrorName() string { return "TagSpecifierValidationError" }
740
741 // Error satisfies the builtin error interface
742 func (e TagSpecifierValidationError) Error() string {
743 cause := ""
744 if e.cause != nil {
745 cause = fmt.Sprintf(" | caused by: %v", e.cause)
746 }
747
748 key := ""
749 if e.key {
750 key = "key for "
751 }
752
753 return fmt.Sprintf(
754 "invalid %sTagSpecifier.%s: %s%s",
755 key,
756 e.field,
757 e.reason,
758 cause)
759 }
760
761 var _ error = TagSpecifierValidationError{}
762
763 var _ interface {
764 Field() string
765 Reason() string
766 Key() bool
767 Cause() error
768 ErrorName() string
769 } = TagSpecifierValidationError{}
770
771 // Validate checks the field values on StatsdSink with the rules defined in the
772 // proto definition for this message. If any rules are violated, the first
773 // error encountered is returned, or nil if there are no violations.
774 func (m *StatsdSink) Validate() error {
775 return m.validate(false)
776 }
777
778 // ValidateAll checks the field values on StatsdSink with the rules defined in
779 // the proto definition for this message. If any rules are violated, the
780 // result is a list of violation errors wrapped in StatsdSinkMultiError, or
781 // nil if none found.
782 func (m *StatsdSink) ValidateAll() error {
783 return m.validate(true)
784 }
785
786 func (m *StatsdSink) validate(all bool) error {
787 if m == nil {
788 return nil
789 }
790
791 var errors []error
792
793 // no validation rules for Prefix
794
795 oneofStatsdSpecifierPresent := false
796 switch v := m.StatsdSpecifier.(type) {
797 case *StatsdSink_Address:
798 if v == nil {
799 err := StatsdSinkValidationError{
800 field: "StatsdSpecifier",
801 reason: "oneof value cannot be a typed-nil",
802 }
803 if !all {
804 return err
805 }
806 errors = append(errors, err)
807 }
808 oneofStatsdSpecifierPresent = true
809
810 if all {
811 switch v := interface{}(m.GetAddress()).(type) {
812 case interface{ ValidateAll() error }:
813 if err := v.ValidateAll(); err != nil {
814 errors = append(errors, StatsdSinkValidationError{
815 field: "Address",
816 reason: "embedded message failed validation",
817 cause: err,
818 })
819 }
820 case interface{ Validate() error }:
821 if err := v.Validate(); err != nil {
822 errors = append(errors, StatsdSinkValidationError{
823 field: "Address",
824 reason: "embedded message failed validation",
825 cause: err,
826 })
827 }
828 }
829 } else if v, ok := interface{}(m.GetAddress()).(interface{ Validate() error }); ok {
830 if err := v.Validate(); err != nil {
831 return StatsdSinkValidationError{
832 field: "Address",
833 reason: "embedded message failed validation",
834 cause: err,
835 }
836 }
837 }
838
839 case *StatsdSink_TcpClusterName:
840 if v == nil {
841 err := StatsdSinkValidationError{
842 field: "StatsdSpecifier",
843 reason: "oneof value cannot be a typed-nil",
844 }
845 if !all {
846 return err
847 }
848 errors = append(errors, err)
849 }
850 oneofStatsdSpecifierPresent = true
851 // no validation rules for TcpClusterName
852 default:
853 _ = v // ensures v is used
854 }
855 if !oneofStatsdSpecifierPresent {
856 err := StatsdSinkValidationError{
857 field: "StatsdSpecifier",
858 reason: "value is required",
859 }
860 if !all {
861 return err
862 }
863 errors = append(errors, err)
864 }
865
866 if len(errors) > 0 {
867 return StatsdSinkMultiError(errors)
868 }
869
870 return nil
871 }
872
873 // StatsdSinkMultiError is an error wrapping multiple validation errors
874 // returned by StatsdSink.ValidateAll() if the designated constraints aren't met.
875 type StatsdSinkMultiError []error
876
877 // Error returns a concatenation of all the error messages it wraps.
878 func (m StatsdSinkMultiError) Error() string {
879 var msgs []string
880 for _, err := range m {
881 msgs = append(msgs, err.Error())
882 }
883 return strings.Join(msgs, "; ")
884 }
885
886 // AllErrors returns a list of validation violation errors.
887 func (m StatsdSinkMultiError) AllErrors() []error { return m }
888
889 // StatsdSinkValidationError is the validation error returned by
890 // StatsdSink.Validate if the designated constraints aren't met.
891 type StatsdSinkValidationError struct {
892 field string
893 reason string
894 cause error
895 key bool
896 }
897
898 // Field function returns field value.
899 func (e StatsdSinkValidationError) Field() string { return e.field }
900
901 // Reason function returns reason value.
902 func (e StatsdSinkValidationError) Reason() string { return e.reason }
903
904 // Cause function returns cause value.
905 func (e StatsdSinkValidationError) Cause() error { return e.cause }
906
907 // Key function returns key value.
908 func (e StatsdSinkValidationError) Key() bool { return e.key }
909
910 // ErrorName returns error name.
911 func (e StatsdSinkValidationError) ErrorName() string { return "StatsdSinkValidationError" }
912
913 // Error satisfies the builtin error interface
914 func (e StatsdSinkValidationError) Error() string {
915 cause := ""
916 if e.cause != nil {
917 cause = fmt.Sprintf(" | caused by: %v", e.cause)
918 }
919
920 key := ""
921 if e.key {
922 key = "key for "
923 }
924
925 return fmt.Sprintf(
926 "invalid %sStatsdSink.%s: %s%s",
927 key,
928 e.field,
929 e.reason,
930 cause)
931 }
932
933 var _ error = StatsdSinkValidationError{}
934
935 var _ interface {
936 Field() string
937 Reason() string
938 Key() bool
939 Cause() error
940 ErrorName() string
941 } = StatsdSinkValidationError{}
942
943 // Validate checks the field values on DogStatsdSink with the rules defined in
944 // the proto definition for this message. If any rules are violated, the first
945 // error encountered is returned, or nil if there are no violations.
946 func (m *DogStatsdSink) Validate() error {
947 return m.validate(false)
948 }
949
950 // ValidateAll checks the field values on DogStatsdSink with the rules defined
951 // in the proto definition for this message. If any rules are violated, the
952 // result is a list of violation errors wrapped in DogStatsdSinkMultiError, or
953 // nil if none found.
954 func (m *DogStatsdSink) ValidateAll() error {
955 return m.validate(true)
956 }
957
958 func (m *DogStatsdSink) validate(all bool) error {
959 if m == nil {
960 return nil
961 }
962
963 var errors []error
964
965 // no validation rules for Prefix
966
967 oneofDogStatsdSpecifierPresent := false
968 switch v := m.DogStatsdSpecifier.(type) {
969 case *DogStatsdSink_Address:
970 if v == nil {
971 err := DogStatsdSinkValidationError{
972 field: "DogStatsdSpecifier",
973 reason: "oneof value cannot be a typed-nil",
974 }
975 if !all {
976 return err
977 }
978 errors = append(errors, err)
979 }
980 oneofDogStatsdSpecifierPresent = true
981
982 if all {
983 switch v := interface{}(m.GetAddress()).(type) {
984 case interface{ ValidateAll() error }:
985 if err := v.ValidateAll(); err != nil {
986 errors = append(errors, DogStatsdSinkValidationError{
987 field: "Address",
988 reason: "embedded message failed validation",
989 cause: err,
990 })
991 }
992 case interface{ Validate() error }:
993 if err := v.Validate(); err != nil {
994 errors = append(errors, DogStatsdSinkValidationError{
995 field: "Address",
996 reason: "embedded message failed validation",
997 cause: err,
998 })
999 }
1000 }
1001 } else if v, ok := interface{}(m.GetAddress()).(interface{ Validate() error }); ok {
1002 if err := v.Validate(); err != nil {
1003 return DogStatsdSinkValidationError{
1004 field: "Address",
1005 reason: "embedded message failed validation",
1006 cause: err,
1007 }
1008 }
1009 }
1010
1011 default:
1012 _ = v // ensures v is used
1013 }
1014 if !oneofDogStatsdSpecifierPresent {
1015 err := DogStatsdSinkValidationError{
1016 field: "DogStatsdSpecifier",
1017 reason: "value is required",
1018 }
1019 if !all {
1020 return err
1021 }
1022 errors = append(errors, err)
1023 }
1024
1025 if len(errors) > 0 {
1026 return DogStatsdSinkMultiError(errors)
1027 }
1028
1029 return nil
1030 }
1031
1032 // DogStatsdSinkMultiError is an error wrapping multiple validation errors
1033 // returned by DogStatsdSink.ValidateAll() if the designated constraints
1034 // aren't met.
1035 type DogStatsdSinkMultiError []error
1036
1037 // Error returns a concatenation of all the error messages it wraps.
1038 func (m DogStatsdSinkMultiError) Error() string {
1039 var msgs []string
1040 for _, err := range m {
1041 msgs = append(msgs, err.Error())
1042 }
1043 return strings.Join(msgs, "; ")
1044 }
1045
1046 // AllErrors returns a list of validation violation errors.
1047 func (m DogStatsdSinkMultiError) AllErrors() []error { return m }
1048
1049 // DogStatsdSinkValidationError is the validation error returned by
1050 // DogStatsdSink.Validate if the designated constraints aren't met.
1051 type DogStatsdSinkValidationError struct {
1052 field string
1053 reason string
1054 cause error
1055 key bool
1056 }
1057
1058 // Field function returns field value.
1059 func (e DogStatsdSinkValidationError) Field() string { return e.field }
1060
1061 // Reason function returns reason value.
1062 func (e DogStatsdSinkValidationError) Reason() string { return e.reason }
1063
1064 // Cause function returns cause value.
1065 func (e DogStatsdSinkValidationError) Cause() error { return e.cause }
1066
1067 // Key function returns key value.
1068 func (e DogStatsdSinkValidationError) Key() bool { return e.key }
1069
1070 // ErrorName returns error name.
1071 func (e DogStatsdSinkValidationError) ErrorName() string { return "DogStatsdSinkValidationError" }
1072
1073 // Error satisfies the builtin error interface
1074 func (e DogStatsdSinkValidationError) Error() string {
1075 cause := ""
1076 if e.cause != nil {
1077 cause = fmt.Sprintf(" | caused by: %v", e.cause)
1078 }
1079
1080 key := ""
1081 if e.key {
1082 key = "key for "
1083 }
1084
1085 return fmt.Sprintf(
1086 "invalid %sDogStatsdSink.%s: %s%s",
1087 key,
1088 e.field,
1089 e.reason,
1090 cause)
1091 }
1092
1093 var _ error = DogStatsdSinkValidationError{}
1094
1095 var _ interface {
1096 Field() string
1097 Reason() string
1098 Key() bool
1099 Cause() error
1100 ErrorName() string
1101 } = DogStatsdSinkValidationError{}
1102
1103 // Validate checks the field values on HystrixSink with the rules defined in
1104 // the proto definition for this message. If any rules are violated, the first
1105 // error encountered is returned, or nil if there are no violations.
1106 func (m *HystrixSink) Validate() error {
1107 return m.validate(false)
1108 }
1109
1110 // ValidateAll checks the field values on HystrixSink with the rules defined in
1111 // the proto definition for this message. If any rules are violated, the
1112 // result is a list of violation errors wrapped in HystrixSinkMultiError, or
1113 // nil if none found.
1114 func (m *HystrixSink) ValidateAll() error {
1115 return m.validate(true)
1116 }
1117
1118 func (m *HystrixSink) validate(all bool) error {
1119 if m == nil {
1120 return nil
1121 }
1122
1123 var errors []error
1124
1125 // no validation rules for NumBuckets
1126
1127 if len(errors) > 0 {
1128 return HystrixSinkMultiError(errors)
1129 }
1130
1131 return nil
1132 }
1133
1134 // HystrixSinkMultiError is an error wrapping multiple validation errors
1135 // returned by HystrixSink.ValidateAll() if the designated constraints aren't met.
1136 type HystrixSinkMultiError []error
1137
1138 // Error returns a concatenation of all the error messages it wraps.
1139 func (m HystrixSinkMultiError) Error() string {
1140 var msgs []string
1141 for _, err := range m {
1142 msgs = append(msgs, err.Error())
1143 }
1144 return strings.Join(msgs, "; ")
1145 }
1146
1147 // AllErrors returns a list of validation violation errors.
1148 func (m HystrixSinkMultiError) AllErrors() []error { return m }
1149
1150 // HystrixSinkValidationError is the validation error returned by
1151 // HystrixSink.Validate if the designated constraints aren't met.
1152 type HystrixSinkValidationError struct {
1153 field string
1154 reason string
1155 cause error
1156 key bool
1157 }
1158
1159 // Field function returns field value.
1160 func (e HystrixSinkValidationError) Field() string { return e.field }
1161
1162 // Reason function returns reason value.
1163 func (e HystrixSinkValidationError) Reason() string { return e.reason }
1164
1165 // Cause function returns cause value.
1166 func (e HystrixSinkValidationError) Cause() error { return e.cause }
1167
1168 // Key function returns key value.
1169 func (e HystrixSinkValidationError) Key() bool { return e.key }
1170
1171 // ErrorName returns error name.
1172 func (e HystrixSinkValidationError) ErrorName() string { return "HystrixSinkValidationError" }
1173
1174 // Error satisfies the builtin error interface
1175 func (e HystrixSinkValidationError) Error() string {
1176 cause := ""
1177 if e.cause != nil {
1178 cause = fmt.Sprintf(" | caused by: %v", e.cause)
1179 }
1180
1181 key := ""
1182 if e.key {
1183 key = "key for "
1184 }
1185
1186 return fmt.Sprintf(
1187 "invalid %sHystrixSink.%s: %s%s",
1188 key,
1189 e.field,
1190 e.reason,
1191 cause)
1192 }
1193
1194 var _ error = HystrixSinkValidationError{}
1195
1196 var _ interface {
1197 Field() string
1198 Reason() string
1199 Key() bool
1200 Cause() error
1201 ErrorName() string
1202 } = HystrixSinkValidationError{}