Debian Codegraph @

envoy/extensions/load_balancing_policies/round_robin/v3/round_robin.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/extensions/load_balancing_policies/round_robin/v3/round_robin.proto
4
5 package round_robinv3
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 RoundRobin 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 *RoundRobin) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on RoundRobin 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 RoundRobinMultiError, or
49 // nil if none found.
50 func (m *RoundRobin) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *RoundRobin) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 if all {
62 switch v := interface{}(m.GetSlowStartConfig()).(type) {
63 case interface{ ValidateAll() error }:
64 if err := v.ValidateAll(); err != nil {
65 errors = append(errors, RoundRobinValidationError{
66 field: "SlowStartConfig",
67 reason: "embedded message failed validation",
68 cause: err,
69 })
70 }
71 case interface{ Validate() error }:
72 if err := v.Validate(); err != nil {
73 errors = append(errors, RoundRobinValidationError{
74 field: "SlowStartConfig",
75 reason: "embedded message failed validation",
76 cause: err,
77 })
78 }
79 }
80 } else if v, ok := interface{}(m.GetSlowStartConfig()).(interface{ Validate() error }); ok {
81 if err := v.Validate(); err != nil {
82 return RoundRobinValidationError{
83 field: "SlowStartConfig",
84 reason: "embedded message failed validation",
85 cause: err,
86 }
87 }
88 }
89
90 if all {
91 switch v := interface{}(m.GetLocalityLbConfig()).(type) {
92 case interface{ ValidateAll() error }:
93 if err := v.ValidateAll(); err != nil {
94 errors = append(errors, RoundRobinValidationError{
95 field: "LocalityLbConfig",
96 reason: "embedded message failed validation",
97 cause: err,
98 })
99 }
100 case interface{ Validate() error }:
101 if err := v.Validate(); err != nil {
102 errors = append(errors, RoundRobinValidationError{
103 field: "LocalityLbConfig",
104 reason: "embedded message failed validation",
105 cause: err,
106 })
107 }
108 }
109 } else if v, ok := interface{}(m.GetLocalityLbConfig()).(interface{ Validate() error }); ok {
110 if err := v.Validate(); err != nil {
111 return RoundRobinValidationError{
112 field: "LocalityLbConfig",
113 reason: "embedded message failed validation",
114 cause: err,
115 }
116 }
117 }
118
119 if len(errors) > 0 {
120 return RoundRobinMultiError(errors)
121 }
122
123 return nil
124 }
125
126 // RoundRobinMultiError is an error wrapping multiple validation errors
127 // returned by RoundRobin.ValidateAll() if the designated constraints aren't met.
128 type RoundRobinMultiError []error
129
130 // Error returns a concatenation of all the error messages it wraps.
131 func (m RoundRobinMultiError) Error() string {
132 var msgs []string
133 for _, err := range m {
134 msgs = append(msgs, err.Error())
135 }
136 return strings.Join(msgs, "; ")
137 }
138
139 // AllErrors returns a list of validation violation errors.
140 func (m RoundRobinMultiError) AllErrors() []error { return m }
141
142 // RoundRobinValidationError is the validation error returned by
143 // RoundRobin.Validate if the designated constraints aren't met.
144 type RoundRobinValidationError struct {
145 field string
146 reason string
147 cause error
148 key bool
149 }
150
151 // Field function returns field value.
152 func (e RoundRobinValidationError) Field() string { return e.field }
153
154 // Reason function returns reason value.
155 func (e RoundRobinValidationError) Reason() string { return e.reason }
156
157 // Cause function returns cause value.
158 func (e RoundRobinValidationError) Cause() error { return e.cause }
159
160 // Key function returns key value.
161 func (e RoundRobinValidationError) Key() bool { return e.key }
162
163 // ErrorName returns error name.
164 func (e RoundRobinValidationError) ErrorName() string { return "RoundRobinValidationError" }
165
166 // Error satisfies the builtin error interface
167 func (e RoundRobinValidationError) Error() string {
168 cause := ""
169 if e.cause != nil {
170 cause = fmt.Sprintf(" | caused by: %v", e.cause)
171 }
172
173 key := ""
174 if e.key {
175 key = "key for "
176 }
177
178 return fmt.Sprintf(
179 "invalid %sRoundRobin.%s: %s%s",
180 key,
181 e.field,
182 e.reason,
183 cause)
184 }
185
186 var _ error = RoundRobinValidationError{}
187
188 var _ interface {
189 Field() string
190 Reason() string
191 Key() bool
192 Cause() error
193 ErrorName() string
194 } = RoundRobinValidationError{}