Debian Codegraph @

envoy/config/common/mutation_rules/v3/mutation_rules.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/common/mutation_rules/v3/mutation_rules.proto
4
5 package mutation_rulesv3
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 HeaderMutationRules with the rules
40 // defined in the proto definition for this message. If any rules are
41 // violated, the first error encountered is returned, or nil if there are no violations.
42 func (m *HeaderMutationRules) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on HeaderMutationRules with the rules
47 // defined in the proto definition for this message. If any rules are
48 // violated, the result is a list of violation errors wrapped in
49 // HeaderMutationRulesMultiError, or nil if none found.
50 func (m *HeaderMutationRules) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *HeaderMutationRules) 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.GetAllowAllRouting()).(type) {
63 case interface{ ValidateAll() error }:
64 if err := v.ValidateAll(); err != nil {
65 errors = append(errors, HeaderMutationRulesValidationError{
66 field: "AllowAllRouting",
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, HeaderMutationRulesValidationError{
74 field: "AllowAllRouting",
75 reason: "embedded message failed validation",
76 cause: err,
77 })
78 }
79 }
80 } else if v, ok := interface{}(m.GetAllowAllRouting()).(interface{ Validate() error }); ok {
81 if err := v.Validate(); err != nil {
82 return HeaderMutationRulesValidationError{
83 field: "AllowAllRouting",
84 reason: "embedded message failed validation",
85 cause: err,
86 }
87 }
88 }
89
90 if all {
91 switch v := interface{}(m.GetAllowEnvoy()).(type) {
92 case interface{ ValidateAll() error }:
93 if err := v.ValidateAll(); err != nil {
94 errors = append(errors, HeaderMutationRulesValidationError{
95 field: "AllowEnvoy",
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, HeaderMutationRulesValidationError{
103 field: "AllowEnvoy",
104 reason: "embedded message failed validation",
105 cause: err,
106 })
107 }
108 }
109 } else if v, ok := interface{}(m.GetAllowEnvoy()).(interface{ Validate() error }); ok {
110 if err := v.Validate(); err != nil {
111 return HeaderMutationRulesValidationError{
112 field: "AllowEnvoy",
113 reason: "embedded message failed validation",
114 cause: err,
115 }
116 }
117 }
118
119 if all {
120 switch v := interface{}(m.GetDisallowSystem()).(type) {
121 case interface{ ValidateAll() error }:
122 if err := v.ValidateAll(); err != nil {
123 errors = append(errors, HeaderMutationRulesValidationError{
124 field: "DisallowSystem",
125 reason: "embedded message failed validation",
126 cause: err,
127 })
128 }
129 case interface{ Validate() error }:
130 if err := v.Validate(); err != nil {
131 errors = append(errors, HeaderMutationRulesValidationError{
132 field: "DisallowSystem",
133 reason: "embedded message failed validation",
134 cause: err,
135 })
136 }
137 }
138 } else if v, ok := interface{}(m.GetDisallowSystem()).(interface{ Validate() error }); ok {
139 if err := v.Validate(); err != nil {
140 return HeaderMutationRulesValidationError{
141 field: "DisallowSystem",
142 reason: "embedded message failed validation",
143 cause: err,
144 }
145 }
146 }
147
148 if all {
149 switch v := interface{}(m.GetDisallowAll()).(type) {
150 case interface{ ValidateAll() error }:
151 if err := v.ValidateAll(); err != nil {
152 errors = append(errors, HeaderMutationRulesValidationError{
153 field: "DisallowAll",
154 reason: "embedded message failed validation",
155 cause: err,
156 })
157 }
158 case interface{ Validate() error }:
159 if err := v.Validate(); err != nil {
160 errors = append(errors, HeaderMutationRulesValidationError{
161 field: "DisallowAll",
162 reason: "embedded message failed validation",
163 cause: err,
164 })
165 }
166 }
167 } else if v, ok := interface{}(m.GetDisallowAll()).(interface{ Validate() error }); ok {
168 if err := v.Validate(); err != nil {
169 return HeaderMutationRulesValidationError{
170 field: "DisallowAll",
171 reason: "embedded message failed validation",
172 cause: err,
173 }
174 }
175 }
176
177 if all {
178 switch v := interface{}(m.GetAllowExpression()).(type) {
179 case interface{ ValidateAll() error }:
180 if err := v.ValidateAll(); err != nil {
181 errors = append(errors, HeaderMutationRulesValidationError{
182 field: "AllowExpression",
183 reason: "embedded message failed validation",
184 cause: err,
185 })
186 }
187 case interface{ Validate() error }:
188 if err := v.Validate(); err != nil {
189 errors = append(errors, HeaderMutationRulesValidationError{
190 field: "AllowExpression",
191 reason: "embedded message failed validation",
192 cause: err,
193 })
194 }
195 }
196 } else if v, ok := interface{}(m.GetAllowExpression()).(interface{ Validate() error }); ok {
197 if err := v.Validate(); err != nil {
198 return HeaderMutationRulesValidationError{
199 field: "AllowExpression",
200 reason: "embedded message failed validation",
201 cause: err,
202 }
203 }
204 }
205
206 if all {
207 switch v := interface{}(m.GetDisallowExpression()).(type) {
208 case interface{ ValidateAll() error }:
209 if err := v.ValidateAll(); err != nil {
210 errors = append(errors, HeaderMutationRulesValidationError{
211 field: "DisallowExpression",
212 reason: "embedded message failed validation",
213 cause: err,
214 })
215 }
216 case interface{ Validate() error }:
217 if err := v.Validate(); err != nil {
218 errors = append(errors, HeaderMutationRulesValidationError{
219 field: "DisallowExpression",
220 reason: "embedded message failed validation",
221 cause: err,
222 })
223 }
224 }
225 } else if v, ok := interface{}(m.GetDisallowExpression()).(interface{ Validate() error }); ok {
226 if err := v.Validate(); err != nil {
227 return HeaderMutationRulesValidationError{
228 field: "DisallowExpression",
229 reason: "embedded message failed validation",
230 cause: err,
231 }
232 }
233 }
234
235 if all {
236 switch v := interface{}(m.GetDisallowIsError()).(type) {
237 case interface{ ValidateAll() error }:
238 if err := v.ValidateAll(); err != nil {
239 errors = append(errors, HeaderMutationRulesValidationError{
240 field: "DisallowIsError",
241 reason: "embedded message failed validation",
242 cause: err,
243 })
244 }
245 case interface{ Validate() error }:
246 if err := v.Validate(); err != nil {
247 errors = append(errors, HeaderMutationRulesValidationError{
248 field: "DisallowIsError",
249 reason: "embedded message failed validation",
250 cause: err,
251 })
252 }
253 }
254 } else if v, ok := interface{}(m.GetDisallowIsError()).(interface{ Validate() error }); ok {
255 if err := v.Validate(); err != nil {
256 return HeaderMutationRulesValidationError{
257 field: "DisallowIsError",
258 reason: "embedded message failed validation",
259 cause: err,
260 }
261 }
262 }
263
264 if len(errors) > 0 {
265 return HeaderMutationRulesMultiError(errors)
266 }
267
268 return nil
269 }
270
271 // HeaderMutationRulesMultiError is an error wrapping multiple validation
272 // errors returned by HeaderMutationRules.ValidateAll() if the designated
273 // constraints aren't met.
274 type HeaderMutationRulesMultiError []error
275
276 // Error returns a concatenation of all the error messages it wraps.
277 func (m HeaderMutationRulesMultiError) Error() string {
278 var msgs []string
279 for _, err := range m {
280 msgs = append(msgs, err.Error())
281 }
282 return strings.Join(msgs, "; ")
283 }
284
285 // AllErrors returns a list of validation violation errors.
286 func (m HeaderMutationRulesMultiError) AllErrors() []error { return m }
287
288 // HeaderMutationRulesValidationError is the validation error returned by
289 // HeaderMutationRules.Validate if the designated constraints aren't met.
290 type HeaderMutationRulesValidationError struct {
291 field string
292 reason string
293 cause error
294 key bool
295 }
296
297 // Field function returns field value.
298 func (e HeaderMutationRulesValidationError) Field() string { return e.field }
299
300 // Reason function returns reason value.
301 func (e HeaderMutationRulesValidationError) Reason() string { return e.reason }
302
303 // Cause function returns cause value.
304 func (e HeaderMutationRulesValidationError) Cause() error { return e.cause }
305
306 // Key function returns key value.
307 func (e HeaderMutationRulesValidationError) Key() bool { return e.key }
308
309 // ErrorName returns error name.
310 func (e HeaderMutationRulesValidationError) ErrorName() string {
311 return "HeaderMutationRulesValidationError"
312 }
313
314 // Error satisfies the builtin error interface
315 func (e HeaderMutationRulesValidationError) Error() string {
316 cause := ""
317 if e.cause != nil {
318 cause = fmt.Sprintf(" | caused by: %v", e.cause)
319 }
320
321 key := ""
322 if e.key {
323 key = "key for "
324 }
325
326 return fmt.Sprintf(
327 "invalid %sHeaderMutationRules.%s: %s%s",
328 key,
329 e.field,
330 e.reason,
331 cause)
332 }
333
334 var _ error = HeaderMutationRulesValidationError{}
335
336 var _ interface {
337 Field() string
338 Reason() string
339 Key() bool
340 Cause() error
341 ErrorName() string
342 } = HeaderMutationRulesValidationError{}
343
344 // Validate checks the field values on HeaderMutation with the rules defined in
345 // the proto definition for this message. If any rules are violated, the first
346 // error encountered is returned, or nil if there are no violations.
347 func (m *HeaderMutation) Validate() error {
348 return m.validate(false)
349 }
350
351 // ValidateAll checks the field values on HeaderMutation with the rules defined
352 // in the proto definition for this message. If any rules are violated, the
353 // result is a list of violation errors wrapped in HeaderMutationMultiError,
354 // or nil if none found.
355 func (m *HeaderMutation) ValidateAll() error {
356 return m.validate(true)
357 }
358
359 func (m *HeaderMutation) validate(all bool) error {
360 if m == nil {
361 return nil
362 }
363
364 var errors []error
365
366 oneofActionPresent := false
367 switch v := m.Action.(type) {
368 case *HeaderMutation_Remove:
369 if v == nil {
370 err := HeaderMutationValidationError{
371 field: "Action",
372 reason: "oneof value cannot be a typed-nil",
373 }
374 if !all {
375 return err
376 }
377 errors = append(errors, err)
378 }
379 oneofActionPresent = true
380
381 if !_HeaderMutation_Remove_Pattern.MatchString(m.GetRemove()) {
382 err := HeaderMutationValidationError{
383 field: "Remove",
384 reason: "value does not match regex pattern \"^[^\\x00\\n\\r]*$\"",
385 }
386 if !all {
387 return err
388 }
389 errors = append(errors, err)
390 }
391
392 case *HeaderMutation_Append:
393 if v == nil {
394 err := HeaderMutationValidationError{
395 field: "Action",
396 reason: "oneof value cannot be a typed-nil",
397 }
398 if !all {
399 return err
400 }
401 errors = append(errors, err)
402 }
403 oneofActionPresent = true
404
405 if all {
406 switch v := interface{}(m.GetAppend()).(type) {
407 case interface{ ValidateAll() error }:
408 if err := v.ValidateAll(); err != nil {
409 errors = append(errors, HeaderMutationValidationError{
410 field: "Append",
411 reason: "embedded message failed validation",
412 cause: err,
413 })
414 }
415 case interface{ Validate() error }:
416 if err := v.Validate(); err != nil {
417 errors = append(errors, HeaderMutationValidationError{
418 field: "Append",
419 reason: "embedded message failed validation",
420 cause: err,
421 })
422 }
423 }
424 } else if v, ok := interface{}(m.GetAppend()).(interface{ Validate() error }); ok {
425 if err := v.Validate(); err != nil {
426 return HeaderMutationValidationError{
427 field: "Append",
428 reason: "embedded message failed validation",
429 cause: err,
430 }
431 }
432 }
433
434 default:
435 _ = v // ensures v is used
436 }
437 if !oneofActionPresent {
438 err := HeaderMutationValidationError{
439 field: "Action",
440 reason: "value is required",
441 }
442 if !all {
443 return err
444 }
445 errors = append(errors, err)
446 }
447
448 if len(errors) > 0 {
449 return HeaderMutationMultiError(errors)
450 }
451
452 return nil
453 }
454
455 // HeaderMutationMultiError is an error wrapping multiple validation errors
456 // returned by HeaderMutation.ValidateAll() if the designated constraints
457 // aren't met.
458 type HeaderMutationMultiError []error
459
460 // Error returns a concatenation of all the error messages it wraps.
461 func (m HeaderMutationMultiError) Error() string {
462 var msgs []string
463 for _, err := range m {
464 msgs = append(msgs, err.Error())
465 }
466 return strings.Join(msgs, "; ")
467 }
468
469 // AllErrors returns a list of validation violation errors.
470 func (m HeaderMutationMultiError) AllErrors() []error { return m }
471
472 // HeaderMutationValidationError is the validation error returned by
473 // HeaderMutation.Validate if the designated constraints aren't met.
474 type HeaderMutationValidationError struct {
475 field string
476 reason string
477 cause error
478 key bool
479 }
480
481 // Field function returns field value.
482 func (e HeaderMutationValidationError) Field() string { return e.field }
483
484 // Reason function returns reason value.
485 func (e HeaderMutationValidationError) Reason() string { return e.reason }
486
487 // Cause function returns cause value.
488 func (e HeaderMutationValidationError) Cause() error { return e.cause }
489
490 // Key function returns key value.
491 func (e HeaderMutationValidationError) Key() bool { return e.key }
492
493 // ErrorName returns error name.
494 func (e HeaderMutationValidationError) ErrorName() string { return "HeaderMutationValidationError" }
495
496 // Error satisfies the builtin error interface
497 func (e HeaderMutationValidationError) Error() string {
498 cause := ""
499 if e.cause != nil {
500 cause = fmt.Sprintf(" | caused by: %v", e.cause)
501 }
502
503 key := ""
504 if e.key {
505 key = "key for "
506 }
507
508 return fmt.Sprintf(
509 "invalid %sHeaderMutation.%s: %s%s",
510 key,
511 e.field,
512 e.reason,
513 cause)
514 }
515
516 var _ error = HeaderMutationValidationError{}
517
518 var _ interface {
519 Field() string
520 Reason() string
521 Key() bool
522 Cause() error
523 ErrorName() string
524 } = HeaderMutationValidationError{}
525
526 var _HeaderMutation_Remove_Pattern = regexp.MustCompile("^[^\x00\n\r]*$")