Debian Codegraph @

envoy/config/trace/v2/http_tracer.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/trace/v2/http_tracer.proto
4
5 package tracev2
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 Tracing 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 *Tracing) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on Tracing 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 TracingMultiError, or nil if none found.
49 func (m *Tracing) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *Tracing) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 if all {
61 switch v := interface{}(m.GetHttp()).(type) {
62 case interface{ ValidateAll() error }:
63 if err := v.ValidateAll(); err != nil {
64 errors = append(errors, TracingValidationError{
65 field: "Http",
66 reason: "embedded message failed validation",
67 cause: err,
68 })
69 }
70 case interface{ Validate() error }:
71 if err := v.Validate(); err != nil {
72 errors = append(errors, TracingValidationError{
73 field: "Http",
74 reason: "embedded message failed validation",
75 cause: err,
76 })
77 }
78 }
79 } else if v, ok := interface{}(m.GetHttp()).(interface{ Validate() error }); ok {
80 if err := v.Validate(); err != nil {
81 return TracingValidationError{
82 field: "Http",
83 reason: "embedded message failed validation",
84 cause: err,
85 }
86 }
87 }
88
89 if len(errors) > 0 {
90 return TracingMultiError(errors)
91 }
92
93 return nil
94 }
95
96 // TracingMultiError is an error wrapping multiple validation errors returned
97 // by Tracing.ValidateAll() if the designated constraints aren't met.
98 type TracingMultiError []error
99
100 // Error returns a concatenation of all the error messages it wraps.
101 func (m TracingMultiError) Error() string {
102 var msgs []string
103 for _, err := range m {
104 msgs = append(msgs, err.Error())
105 }
106 return strings.Join(msgs, "; ")
107 }
108
109 // AllErrors returns a list of validation violation errors.
110 func (m TracingMultiError) AllErrors() []error { return m }
111
112 // TracingValidationError is the validation error returned by Tracing.Validate
113 // if the designated constraints aren't met.
114 type TracingValidationError struct {
115 field string
116 reason string
117 cause error
118 key bool
119 }
120
121 // Field function returns field value.
122 func (e TracingValidationError) Field() string { return e.field }
123
124 // Reason function returns reason value.
125 func (e TracingValidationError) Reason() string { return e.reason }
126
127 // Cause function returns cause value.
128 func (e TracingValidationError) Cause() error { return e.cause }
129
130 // Key function returns key value.
131 func (e TracingValidationError) Key() bool { return e.key }
132
133 // ErrorName returns error name.
134 func (e TracingValidationError) ErrorName() string { return "TracingValidationError" }
135
136 // Error satisfies the builtin error interface
137 func (e TracingValidationError) Error() string {
138 cause := ""
139 if e.cause != nil {
140 cause = fmt.Sprintf(" | caused by: %v", e.cause)
141 }
142
143 key := ""
144 if e.key {
145 key = "key for "
146 }
147
148 return fmt.Sprintf(
149 "invalid %sTracing.%s: %s%s",
150 key,
151 e.field,
152 e.reason,
153 cause)
154 }
155
156 var _ error = TracingValidationError{}
157
158 var _ interface {
159 Field() string
160 Reason() string
161 Key() bool
162 Cause() error
163 ErrorName() string
164 } = TracingValidationError{}
165
166 // Validate checks the field values on Tracing_Http with the rules defined in
167 // the proto definition for this message. If any rules are violated, the first
168 // error encountered is returned, or nil if there are no violations.
169 func (m *Tracing_Http) Validate() error {
170 return m.validate(false)
171 }
172
173 // ValidateAll checks the field values on Tracing_Http with the rules defined
174 // in the proto definition for this message. If any rules are violated, the
175 // result is a list of violation errors wrapped in Tracing_HttpMultiError, or
176 // nil if none found.
177 func (m *Tracing_Http) ValidateAll() error {
178 return m.validate(true)
179 }
180
181 func (m *Tracing_Http) validate(all bool) error {
182 if m == nil {
183 return nil
184 }
185
186 var errors []error
187
188 if len(m.GetName()) < 1 {
189 err := Tracing_HttpValidationError{
190 field: "Name",
191 reason: "value length must be at least 1 bytes",
192 }
193 if !all {
194 return err
195 }
196 errors = append(errors, err)
197 }
198
199 switch v := m.ConfigType.(type) {
200 case *Tracing_Http_Config:
201 if v == nil {
202 err := Tracing_HttpValidationError{
203 field: "ConfigType",
204 reason: "oneof value cannot be a typed-nil",
205 }
206 if !all {
207 return err
208 }
209 errors = append(errors, err)
210 }
211
212 if all {
213 switch v := interface{}(m.GetConfig()).(type) {
214 case interface{ ValidateAll() error }:
215 if err := v.ValidateAll(); err != nil {
216 errors = append(errors, Tracing_HttpValidationError{
217 field: "Config",
218 reason: "embedded message failed validation",
219 cause: err,
220 })
221 }
222 case interface{ Validate() error }:
223 if err := v.Validate(); err != nil {
224 errors = append(errors, Tracing_HttpValidationError{
225 field: "Config",
226 reason: "embedded message failed validation",
227 cause: err,
228 })
229 }
230 }
231 } else if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok {
232 if err := v.Validate(); err != nil {
233 return Tracing_HttpValidationError{
234 field: "Config",
235 reason: "embedded message failed validation",
236 cause: err,
237 }
238 }
239 }
240
241 case *Tracing_Http_TypedConfig:
242 if v == nil {
243 err := Tracing_HttpValidationError{
244 field: "ConfigType",
245 reason: "oneof value cannot be a typed-nil",
246 }
247 if !all {
248 return err
249 }
250 errors = append(errors, err)
251 }
252
253 if all {
254 switch v := interface{}(m.GetTypedConfig()).(type) {
255 case interface{ ValidateAll() error }:
256 if err := v.ValidateAll(); err != nil {
257 errors = append(errors, Tracing_HttpValidationError{
258 field: "TypedConfig",
259 reason: "embedded message failed validation",
260 cause: err,
261 })
262 }
263 case interface{ Validate() error }:
264 if err := v.Validate(); err != nil {
265 errors = append(errors, Tracing_HttpValidationError{
266 field: "TypedConfig",
267 reason: "embedded message failed validation",
268 cause: err,
269 })
270 }
271 }
272 } else if v, ok := interface{}(m.GetTypedConfig()).(interface{ Validate() error }); ok {
273 if err := v.Validate(); err != nil {
274 return Tracing_HttpValidationError{
275 field: "TypedConfig",
276 reason: "embedded message failed validation",
277 cause: err,
278 }
279 }
280 }
281
282 default:
283 _ = v // ensures v is used
284 }
285
286 if len(errors) > 0 {
287 return Tracing_HttpMultiError(errors)
288 }
289
290 return nil
291 }
292
293 // Tracing_HttpMultiError is an error wrapping multiple validation errors
294 // returned by Tracing_Http.ValidateAll() if the designated constraints aren't met.
295 type Tracing_HttpMultiError []error
296
297 // Error returns a concatenation of all the error messages it wraps.
298 func (m Tracing_HttpMultiError) Error() string {
299 var msgs []string
300 for _, err := range m {
301 msgs = append(msgs, err.Error())
302 }
303 return strings.Join(msgs, "; ")
304 }
305
306 // AllErrors returns a list of validation violation errors.
307 func (m Tracing_HttpMultiError) AllErrors() []error { return m }
308
309 // Tracing_HttpValidationError is the validation error returned by
310 // Tracing_Http.Validate if the designated constraints aren't met.
311 type Tracing_HttpValidationError struct {
312 field string
313 reason string
314 cause error
315 key bool
316 }
317
318 // Field function returns field value.
319 func (e Tracing_HttpValidationError) Field() string { return e.field }
320
321 // Reason function returns reason value.
322 func (e Tracing_HttpValidationError) Reason() string { return e.reason }
323
324 // Cause function returns cause value.
325 func (e Tracing_HttpValidationError) Cause() error { return e.cause }
326
327 // Key function returns key value.
328 func (e Tracing_HttpValidationError) Key() bool { return e.key }
329
330 // ErrorName returns error name.
331 func (e Tracing_HttpValidationError) ErrorName() string { return "Tracing_HttpValidationError" }
332
333 // Error satisfies the builtin error interface
334 func (e Tracing_HttpValidationError) Error() string {
335 cause := ""
336 if e.cause != nil {
337 cause = fmt.Sprintf(" | caused by: %v", e.cause)
338 }
339
340 key := ""
341 if e.key {
342 key = "key for "
343 }
344
345 return fmt.Sprintf(
346 "invalid %sTracing_Http.%s: %s%s",
347 key,
348 e.field,
349 e.reason,
350 cause)
351 }
352
353 var _ error = Tracing_HttpValidationError{}
354
355 var _ interface {
356 Field() string
357 Reason() string
358 Key() bool
359 Cause() error
360 ErrorName() string
361 } = Tracing_HttpValidationError{}