1
2
3
4 package authv2
5
6 import (
7 "bytes"
8 "errors"
9 "fmt"
10 "net"
11 "net/mail"
12 "net/url"
13 "regexp"
14 "sort"
15 "strings"
16 "time"
17 "unicode/utf8"
18
19 "google.golang.org/protobuf/types/known/anypb"
20 )
21
22
23 var (
24 _ = bytes.MinRead
25 _ = errors.New("")
26 _ = fmt.Print
27 _ = utf8.UTFMax
28 _ = (*regexp.Regexp)(nil)
29 _ = (*strings.Reader)(nil)
30 _ = net.IPv4len
31 _ = time.Duration(0)
32 _ = (*url.URL)(nil)
33 _ = (*mail.Address)(nil)
34 _ = anypb.Any{}
35 _ = sort.Sort
36 )
37
38
39
40
41 func (m *AttributeContext) Validate() error {
42 return m.validate(false)
43 }
44
45
46
47
48
49 func (m *AttributeContext) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *AttributeContext) 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.GetSource()).(type) {
62 case interface{ ValidateAll() error }:
63 if err := v.ValidateAll(); err != nil {
64 errors = append(errors, AttributeContextValidationError{
65 field: "Source",
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, AttributeContextValidationError{
73 field: "Source",
74 reason: "embedded message failed validation",
75 cause: err,
76 })
77 }
78 }
79 } else if v, ok := interface{}(m.GetSource()).(interface{ Validate() error }); ok {
80 if err := v.Validate(); err != nil {
81 return AttributeContextValidationError{
82 field: "Source",
83 reason: "embedded message failed validation",
84 cause: err,
85 }
86 }
87 }
88
89 if all {
90 switch v := interface{}(m.GetDestination()).(type) {
91 case interface{ ValidateAll() error }:
92 if err := v.ValidateAll(); err != nil {
93 errors = append(errors, AttributeContextValidationError{
94 field: "Destination",
95 reason: "embedded message failed validation",
96 cause: err,
97 })
98 }
99 case interface{ Validate() error }:
100 if err := v.Validate(); err != nil {
101 errors = append(errors, AttributeContextValidationError{
102 field: "Destination",
103 reason: "embedded message failed validation",
104 cause: err,
105 })
106 }
107 }
108 } else if v, ok := interface{}(m.GetDestination()).(interface{ Validate() error }); ok {
109 if err := v.Validate(); err != nil {
110 return AttributeContextValidationError{
111 field: "Destination",
112 reason: "embedded message failed validation",
113 cause: err,
114 }
115 }
116 }
117
118 if all {
119 switch v := interface{}(m.GetRequest()).(type) {
120 case interface{ ValidateAll() error }:
121 if err := v.ValidateAll(); err != nil {
122 errors = append(errors, AttributeContextValidationError{
123 field: "Request",
124 reason: "embedded message failed validation",
125 cause: err,
126 })
127 }
128 case interface{ Validate() error }:
129 if err := v.Validate(); err != nil {
130 errors = append(errors, AttributeContextValidationError{
131 field: "Request",
132 reason: "embedded message failed validation",
133 cause: err,
134 })
135 }
136 }
137 } else if v, ok := interface{}(m.GetRequest()).(interface{ Validate() error }); ok {
138 if err := v.Validate(); err != nil {
139 return AttributeContextValidationError{
140 field: "Request",
141 reason: "embedded message failed validation",
142 cause: err,
143 }
144 }
145 }
146
147
148
149 if all {
150 switch v := interface{}(m.GetMetadataContext()).(type) {
151 case interface{ ValidateAll() error }:
152 if err := v.ValidateAll(); err != nil {
153 errors = append(errors, AttributeContextValidationError{
154 field: "MetadataContext",
155 reason: "embedded message failed validation",
156 cause: err,
157 })
158 }
159 case interface{ Validate() error }:
160 if err := v.Validate(); err != nil {
161 errors = append(errors, AttributeContextValidationError{
162 field: "MetadataContext",
163 reason: "embedded message failed validation",
164 cause: err,
165 })
166 }
167 }
168 } else if v, ok := interface{}(m.GetMetadataContext()).(interface{ Validate() error }); ok {
169 if err := v.Validate(); err != nil {
170 return AttributeContextValidationError{
171 field: "MetadataContext",
172 reason: "embedded message failed validation",
173 cause: err,
174 }
175 }
176 }
177
178 if len(errors) > 0 {
179 return AttributeContextMultiError(errors)
180 }
181
182 return nil
183 }
184
185
186
187
188 type AttributeContextMultiError []error
189
190
191 func (m AttributeContextMultiError) Error() string {
192 var msgs []string
193 for _, err := range m {
194 msgs = append(msgs, err.Error())
195 }
196 return strings.Join(msgs, "; ")
197 }
198
199
200 func (m AttributeContextMultiError) AllErrors() []error { return m }
201
202
203
204 type AttributeContextValidationError struct {
205 field string
206 reason string
207 cause error
208 key bool
209 }
210
211
212 func (e AttributeContextValidationError) Field() string { return e.field }
213
214
215 func (e AttributeContextValidationError) Reason() string { return e.reason }
216
217
218 func (e AttributeContextValidationError) Cause() error { return e.cause }
219
220
221 func (e AttributeContextValidationError) Key() bool { return e.key }
222
223
224 func (e AttributeContextValidationError) ErrorName() string { return "AttributeContextValidationError" }
225
226
227 func (e AttributeContextValidationError) Error() string {
228 cause := ""
229 if e.cause != nil {
230 cause = fmt.Sprintf(" | caused by: %v", e.cause)
231 }
232
233 key := ""
234 if e.key {
235 key = "key for "
236 }
237
238 return fmt.Sprintf(
239 "invalid %sAttributeContext.%s: %s%s",
240 key,
241 e.field,
242 e.reason,
243 cause)
244 }
245
246 var _ error = AttributeContextValidationError{}
247
248 var _ interface {
249 Field() string
250 Reason() string
251 Key() bool
252 Cause() error
253 ErrorName() string
254 } = AttributeContextValidationError{}
255
256
257
258
259 func (m *AttributeContext_Peer) Validate() error {
260 return m.validate(false)
261 }
262
263
264
265
266
267 func (m *AttributeContext_Peer) ValidateAll() error {
268 return m.validate(true)
269 }
270
271 func (m *AttributeContext_Peer) validate(all bool) error {
272 if m == nil {
273 return nil
274 }
275
276 var errors []error
277
278 if all {
279 switch v := interface{}(m.GetAddress()).(type) {
280 case interface{ ValidateAll() error }:
281 if err := v.ValidateAll(); err != nil {
282 errors = append(errors, AttributeContext_PeerValidationError{
283 field: "Address",
284 reason: "embedded message failed validation",
285 cause: err,
286 })
287 }
288 case interface{ Validate() error }:
289 if err := v.Validate(); err != nil {
290 errors = append(errors, AttributeContext_PeerValidationError{
291 field: "Address",
292 reason: "embedded message failed validation",
293 cause: err,
294 })
295 }
296 }
297 } else if v, ok := interface{}(m.GetAddress()).(interface{ Validate() error }); ok {
298 if err := v.Validate(); err != nil {
299 return AttributeContext_PeerValidationError{
300 field: "Address",
301 reason: "embedded message failed validation",
302 cause: err,
303 }
304 }
305 }
306
307
308
309
310
311
312
313
314
315 if len(errors) > 0 {
316 return AttributeContext_PeerMultiError(errors)
317 }
318
319 return nil
320 }
321
322
323
324
325 type AttributeContext_PeerMultiError []error
326
327
328 func (m AttributeContext_PeerMultiError) Error() string {
329 var msgs []string
330 for _, err := range m {
331 msgs = append(msgs, err.Error())
332 }
333 return strings.Join(msgs, "; ")
334 }
335
336
337 func (m AttributeContext_PeerMultiError) AllErrors() []error { return m }
338
339
340
341 type AttributeContext_PeerValidationError struct {
342 field string
343 reason string
344 cause error
345 key bool
346 }
347
348
349 func (e AttributeContext_PeerValidationError) Field() string { return e.field }
350
351
352 func (e AttributeContext_PeerValidationError) Reason() string { return e.reason }
353
354
355 func (e AttributeContext_PeerValidationError) Cause() error { return e.cause }
356
357
358 func (e AttributeContext_PeerValidationError) Key() bool { return e.key }
359
360
361 func (e AttributeContext_PeerValidationError) ErrorName() string {
362 return "AttributeContext_PeerValidationError"
363 }
364
365
366 func (e AttributeContext_PeerValidationError) Error() string {
367 cause := ""
368 if e.cause != nil {
369 cause = fmt.Sprintf(" | caused by: %v", e.cause)
370 }
371
372 key := ""
373 if e.key {
374 key = "key for "
375 }
376
377 return fmt.Sprintf(
378 "invalid %sAttributeContext_Peer.%s: %s%s",
379 key,
380 e.field,
381 e.reason,
382 cause)
383 }
384
385 var _ error = AttributeContext_PeerValidationError{}
386
387 var _ interface {
388 Field() string
389 Reason() string
390 Key() bool
391 Cause() error
392 ErrorName() string
393 } = AttributeContext_PeerValidationError{}
394
395
396
397
398 func (m *AttributeContext_Request) Validate() error {
399 return m.validate(false)
400 }
401
402
403
404
405
406 func (m *AttributeContext_Request) ValidateAll() error {
407 return m.validate(true)
408 }
409
410 func (m *AttributeContext_Request) validate(all bool) error {
411 if m == nil {
412 return nil
413 }
414
415 var errors []error
416
417 if all {
418 switch v := interface{}(m.GetTime()).(type) {
419 case interface{ ValidateAll() error }:
420 if err := v.ValidateAll(); err != nil {
421 errors = append(errors, AttributeContext_RequestValidationError{
422 field: "Time",
423 reason: "embedded message failed validation",
424 cause: err,
425 })
426 }
427 case interface{ Validate() error }:
428 if err := v.Validate(); err != nil {
429 errors = append(errors, AttributeContext_RequestValidationError{
430 field: "Time",
431 reason: "embedded message failed validation",
432 cause: err,
433 })
434 }
435 }
436 } else if v, ok := interface{}(m.GetTime()).(interface{ Validate() error }); ok {
437 if err := v.Validate(); err != nil {
438 return AttributeContext_RequestValidationError{
439 field: "Time",
440 reason: "embedded message failed validation",
441 cause: err,
442 }
443 }
444 }
445
446 if all {
447 switch v := interface{}(m.GetHttp()).(type) {
448 case interface{ ValidateAll() error }:
449 if err := v.ValidateAll(); err != nil {
450 errors = append(errors, AttributeContext_RequestValidationError{
451 field: "Http",
452 reason: "embedded message failed validation",
453 cause: err,
454 })
455 }
456 case interface{ Validate() error }:
457 if err := v.Validate(); err != nil {
458 errors = append(errors, AttributeContext_RequestValidationError{
459 field: "Http",
460 reason: "embedded message failed validation",
461 cause: err,
462 })
463 }
464 }
465 } else if v, ok := interface{}(m.GetHttp()).(interface{ Validate() error }); ok {
466 if err := v.Validate(); err != nil {
467 return AttributeContext_RequestValidationError{
468 field: "Http",
469 reason: "embedded message failed validation",
470 cause: err,
471 }
472 }
473 }
474
475 if len(errors) > 0 {
476 return AttributeContext_RequestMultiError(errors)
477 }
478
479 return nil
480 }
481
482
483
484
485 type AttributeContext_RequestMultiError []error
486
487
488 func (m AttributeContext_RequestMultiError) Error() string {
489 var msgs []string
490 for _, err := range m {
491 msgs = append(msgs, err.Error())
492 }
493 return strings.Join(msgs, "; ")
494 }
495
496
497 func (m AttributeContext_RequestMultiError) AllErrors() []error { return m }
498
499
500
501 type AttributeContext_RequestValidationError struct {
502 field string
503 reason string
504 cause error
505 key bool
506 }
507
508
509 func (e AttributeContext_RequestValidationError) Field() string { return e.field }
510
511
512 func (e AttributeContext_RequestValidationError) Reason() string { return e.reason }
513
514
515 func (e AttributeContext_RequestValidationError) Cause() error { return e.cause }
516
517
518 func (e AttributeContext_RequestValidationError) Key() bool { return e.key }
519
520
521 func (e AttributeContext_RequestValidationError) ErrorName() string {
522 return "AttributeContext_RequestValidationError"
523 }
524
525
526 func (e AttributeContext_RequestValidationError) Error() string {
527 cause := ""
528 if e.cause != nil {
529 cause = fmt.Sprintf(" | caused by: %v", e.cause)
530 }
531
532 key := ""
533 if e.key {
534 key = "key for "
535 }
536
537 return fmt.Sprintf(
538 "invalid %sAttributeContext_Request.%s: %s%s",
539 key,
540 e.field,
541 e.reason,
542 cause)
543 }
544
545 var _ error = AttributeContext_RequestValidationError{}
546
547 var _ interface {
548 Field() string
549 Reason() string
550 Key() bool
551 Cause() error
552 ErrorName() string
553 } = AttributeContext_RequestValidationError{}
554
555
556
557
558 func (m *AttributeContext_HttpRequest) Validate() error {
559 return m.validate(false)
560 }
561
562
563
564
565
566 func (m *AttributeContext_HttpRequest) ValidateAll() error {
567 return m.validate(true)
568 }
569
570 func (m *AttributeContext_HttpRequest) validate(all bool) error {
571 if m == nil {
572 return nil
573 }
574
575 var errors []error
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599 if len(errors) > 0 {
600 return AttributeContext_HttpRequestMultiError(errors)
601 }
602
603 return nil
604 }
605
606
607
608
609 type AttributeContext_HttpRequestMultiError []error
610
611
612 func (m AttributeContext_HttpRequestMultiError) Error() string {
613 var msgs []string
614 for _, err := range m {
615 msgs = append(msgs, err.Error())
616 }
617 return strings.Join(msgs, "; ")
618 }
619
620
621 func (m AttributeContext_HttpRequestMultiError) AllErrors() []error { return m }
622
623
624
625
626 type AttributeContext_HttpRequestValidationError struct {
627 field string
628 reason string
629 cause error
630 key bool
631 }
632
633
634 func (e AttributeContext_HttpRequestValidationError) Field() string { return e.field }
635
636
637 func (e AttributeContext_HttpRequestValidationError) Reason() string { return e.reason }
638
639
640 func (e AttributeContext_HttpRequestValidationError) Cause() error { return e.cause }
641
642
643 func (e AttributeContext_HttpRequestValidationError) Key() bool { return e.key }
644
645
646 func (e AttributeContext_HttpRequestValidationError) ErrorName() string {
647 return "AttributeContext_HttpRequestValidationError"
648 }
649
650
651 func (e AttributeContext_HttpRequestValidationError) Error() string {
652 cause := ""
653 if e.cause != nil {
654 cause = fmt.Sprintf(" | caused by: %v", e.cause)
655 }
656
657 key := ""
658 if e.key {
659 key = "key for "
660 }
661
662 return fmt.Sprintf(
663 "invalid %sAttributeContext_HttpRequest.%s: %s%s",
664 key,
665 e.field,
666 e.reason,
667 cause)
668 }
669
670 var _ error = AttributeContext_HttpRequestValidationError{}
671
672 var _ interface {
673 Field() string
674 Reason() string
675 Key() bool
676 Cause() error
677 ErrorName() string
678 } = AttributeContext_HttpRequestValidationError{}
679
View as plain text