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 *CheckRequest) Validate() error {
42 return m.validate(false)
43 }
44
45
46
47
48
49 func (m *CheckRequest) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *CheckRequest) 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.GetAttributes()).(type) {
62 case interface{ ValidateAll() error }:
63 if err := v.ValidateAll(); err != nil {
64 errors = append(errors, CheckRequestValidationError{
65 field: "Attributes",
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, CheckRequestValidationError{
73 field: "Attributes",
74 reason: "embedded message failed validation",
75 cause: err,
76 })
77 }
78 }
79 } else if v, ok := interface{}(m.GetAttributes()).(interface{ Validate() error }); ok {
80 if err := v.Validate(); err != nil {
81 return CheckRequestValidationError{
82 field: "Attributes",
83 reason: "embedded message failed validation",
84 cause: err,
85 }
86 }
87 }
88
89 if len(errors) > 0 {
90 return CheckRequestMultiError(errors)
91 }
92
93 return nil
94 }
95
96
97
98 type CheckRequestMultiError []error
99
100
101 func (m CheckRequestMultiError) 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
110 func (m CheckRequestMultiError) AllErrors() []error { return m }
111
112
113
114 type CheckRequestValidationError struct {
115 field string
116 reason string
117 cause error
118 key bool
119 }
120
121
122 func (e CheckRequestValidationError) Field() string { return e.field }
123
124
125 func (e CheckRequestValidationError) Reason() string { return e.reason }
126
127
128 func (e CheckRequestValidationError) Cause() error { return e.cause }
129
130
131 func (e CheckRequestValidationError) Key() bool { return e.key }
132
133
134 func (e CheckRequestValidationError) ErrorName() string { return "CheckRequestValidationError" }
135
136
137 func (e CheckRequestValidationError) 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 %sCheckRequest.%s: %s%s",
150 key,
151 e.field,
152 e.reason,
153 cause)
154 }
155
156 var _ error = CheckRequestValidationError{}
157
158 var _ interface {
159 Field() string
160 Reason() string
161 Key() bool
162 Cause() error
163 ErrorName() string
164 } = CheckRequestValidationError{}
165
166
167
168
169 func (m *DeniedHttpResponse) Validate() error {
170 return m.validate(false)
171 }
172
173
174
175
176
177 func (m *DeniedHttpResponse) ValidateAll() error {
178 return m.validate(true)
179 }
180
181 func (m *DeniedHttpResponse) validate(all bool) error {
182 if m == nil {
183 return nil
184 }
185
186 var errors []error
187
188 if m.GetStatus() == nil {
189 err := DeniedHttpResponseValidationError{
190 field: "Status",
191 reason: "value is required",
192 }
193 if !all {
194 return err
195 }
196 errors = append(errors, err)
197 }
198
199 if all {
200 switch v := interface{}(m.GetStatus()).(type) {
201 case interface{ ValidateAll() error }:
202 if err := v.ValidateAll(); err != nil {
203 errors = append(errors, DeniedHttpResponseValidationError{
204 field: "Status",
205 reason: "embedded message failed validation",
206 cause: err,
207 })
208 }
209 case interface{ Validate() error }:
210 if err := v.Validate(); err != nil {
211 errors = append(errors, DeniedHttpResponseValidationError{
212 field: "Status",
213 reason: "embedded message failed validation",
214 cause: err,
215 })
216 }
217 }
218 } else if v, ok := interface{}(m.GetStatus()).(interface{ Validate() error }); ok {
219 if err := v.Validate(); err != nil {
220 return DeniedHttpResponseValidationError{
221 field: "Status",
222 reason: "embedded message failed validation",
223 cause: err,
224 }
225 }
226 }
227
228 for idx, item := range m.GetHeaders() {
229 _, _ = idx, item
230
231 if all {
232 switch v := interface{}(item).(type) {
233 case interface{ ValidateAll() error }:
234 if err := v.ValidateAll(); err != nil {
235 errors = append(errors, DeniedHttpResponseValidationError{
236 field: fmt.Sprintf("Headers[%v]", idx),
237 reason: "embedded message failed validation",
238 cause: err,
239 })
240 }
241 case interface{ Validate() error }:
242 if err := v.Validate(); err != nil {
243 errors = append(errors, DeniedHttpResponseValidationError{
244 field: fmt.Sprintf("Headers[%v]", idx),
245 reason: "embedded message failed validation",
246 cause: err,
247 })
248 }
249 }
250 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
251 if err := v.Validate(); err != nil {
252 return DeniedHttpResponseValidationError{
253 field: fmt.Sprintf("Headers[%v]", idx),
254 reason: "embedded message failed validation",
255 cause: err,
256 }
257 }
258 }
259
260 }
261
262
263
264 if len(errors) > 0 {
265 return DeniedHttpResponseMultiError(errors)
266 }
267
268 return nil
269 }
270
271
272
273
274 type DeniedHttpResponseMultiError []error
275
276
277 func (m DeniedHttpResponseMultiError) 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
286 func (m DeniedHttpResponseMultiError) AllErrors() []error { return m }
287
288
289
290 type DeniedHttpResponseValidationError struct {
291 field string
292 reason string
293 cause error
294 key bool
295 }
296
297
298 func (e DeniedHttpResponseValidationError) Field() string { return e.field }
299
300
301 func (e DeniedHttpResponseValidationError) Reason() string { return e.reason }
302
303
304 func (e DeniedHttpResponseValidationError) Cause() error { return e.cause }
305
306
307 func (e DeniedHttpResponseValidationError) Key() bool { return e.key }
308
309
310 func (e DeniedHttpResponseValidationError) ErrorName() string {
311 return "DeniedHttpResponseValidationError"
312 }
313
314
315 func (e DeniedHttpResponseValidationError) 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 %sDeniedHttpResponse.%s: %s%s",
328 key,
329 e.field,
330 e.reason,
331 cause)
332 }
333
334 var _ error = DeniedHttpResponseValidationError{}
335
336 var _ interface {
337 Field() string
338 Reason() string
339 Key() bool
340 Cause() error
341 ErrorName() string
342 } = DeniedHttpResponseValidationError{}
343
344
345
346
347 func (m *OkHttpResponse) Validate() error {
348 return m.validate(false)
349 }
350
351
352
353
354
355 func (m *OkHttpResponse) ValidateAll() error {
356 return m.validate(true)
357 }
358
359 func (m *OkHttpResponse) validate(all bool) error {
360 if m == nil {
361 return nil
362 }
363
364 var errors []error
365
366 for idx, item := range m.GetHeaders() {
367 _, _ = idx, item
368
369 if all {
370 switch v := interface{}(item).(type) {
371 case interface{ ValidateAll() error }:
372 if err := v.ValidateAll(); err != nil {
373 errors = append(errors, OkHttpResponseValidationError{
374 field: fmt.Sprintf("Headers[%v]", idx),
375 reason: "embedded message failed validation",
376 cause: err,
377 })
378 }
379 case interface{ Validate() error }:
380 if err := v.Validate(); err != nil {
381 errors = append(errors, OkHttpResponseValidationError{
382 field: fmt.Sprintf("Headers[%v]", idx),
383 reason: "embedded message failed validation",
384 cause: err,
385 })
386 }
387 }
388 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
389 if err := v.Validate(); err != nil {
390 return OkHttpResponseValidationError{
391 field: fmt.Sprintf("Headers[%v]", idx),
392 reason: "embedded message failed validation",
393 cause: err,
394 }
395 }
396 }
397
398 }
399
400 if len(errors) > 0 {
401 return OkHttpResponseMultiError(errors)
402 }
403
404 return nil
405 }
406
407
408
409
410 type OkHttpResponseMultiError []error
411
412
413 func (m OkHttpResponseMultiError) Error() string {
414 var msgs []string
415 for _, err := range m {
416 msgs = append(msgs, err.Error())
417 }
418 return strings.Join(msgs, "; ")
419 }
420
421
422 func (m OkHttpResponseMultiError) AllErrors() []error { return m }
423
424
425
426 type OkHttpResponseValidationError struct {
427 field string
428 reason string
429 cause error
430 key bool
431 }
432
433
434 func (e OkHttpResponseValidationError) Field() string { return e.field }
435
436
437 func (e OkHttpResponseValidationError) Reason() string { return e.reason }
438
439
440 func (e OkHttpResponseValidationError) Cause() error { return e.cause }
441
442
443 func (e OkHttpResponseValidationError) Key() bool { return e.key }
444
445
446 func (e OkHttpResponseValidationError) ErrorName() string { return "OkHttpResponseValidationError" }
447
448
449 func (e OkHttpResponseValidationError) Error() string {
450 cause := ""
451 if e.cause != nil {
452 cause = fmt.Sprintf(" | caused by: %v", e.cause)
453 }
454
455 key := ""
456 if e.key {
457 key = "key for "
458 }
459
460 return fmt.Sprintf(
461 "invalid %sOkHttpResponse.%s: %s%s",
462 key,
463 e.field,
464 e.reason,
465 cause)
466 }
467
468 var _ error = OkHttpResponseValidationError{}
469
470 var _ interface {
471 Field() string
472 Reason() string
473 Key() bool
474 Cause() error
475 ErrorName() string
476 } = OkHttpResponseValidationError{}
477
478
479
480
481 func (m *CheckResponse) Validate() error {
482 return m.validate(false)
483 }
484
485
486
487
488
489 func (m *CheckResponse) ValidateAll() error {
490 return m.validate(true)
491 }
492
493 func (m *CheckResponse) validate(all bool) error {
494 if m == nil {
495 return nil
496 }
497
498 var errors []error
499
500 if all {
501 switch v := interface{}(m.GetStatus()).(type) {
502 case interface{ ValidateAll() error }:
503 if err := v.ValidateAll(); err != nil {
504 errors = append(errors, CheckResponseValidationError{
505 field: "Status",
506 reason: "embedded message failed validation",
507 cause: err,
508 })
509 }
510 case interface{ Validate() error }:
511 if err := v.Validate(); err != nil {
512 errors = append(errors, CheckResponseValidationError{
513 field: "Status",
514 reason: "embedded message failed validation",
515 cause: err,
516 })
517 }
518 }
519 } else if v, ok := interface{}(m.GetStatus()).(interface{ Validate() error }); ok {
520 if err := v.Validate(); err != nil {
521 return CheckResponseValidationError{
522 field: "Status",
523 reason: "embedded message failed validation",
524 cause: err,
525 }
526 }
527 }
528
529 switch v := m.HttpResponse.(type) {
530 case *CheckResponse_DeniedResponse:
531 if v == nil {
532 err := CheckResponseValidationError{
533 field: "HttpResponse",
534 reason: "oneof value cannot be a typed-nil",
535 }
536 if !all {
537 return err
538 }
539 errors = append(errors, err)
540 }
541
542 if all {
543 switch v := interface{}(m.GetDeniedResponse()).(type) {
544 case interface{ ValidateAll() error }:
545 if err := v.ValidateAll(); err != nil {
546 errors = append(errors, CheckResponseValidationError{
547 field: "DeniedResponse",
548 reason: "embedded message failed validation",
549 cause: err,
550 })
551 }
552 case interface{ Validate() error }:
553 if err := v.Validate(); err != nil {
554 errors = append(errors, CheckResponseValidationError{
555 field: "DeniedResponse",
556 reason: "embedded message failed validation",
557 cause: err,
558 })
559 }
560 }
561 } else if v, ok := interface{}(m.GetDeniedResponse()).(interface{ Validate() error }); ok {
562 if err := v.Validate(); err != nil {
563 return CheckResponseValidationError{
564 field: "DeniedResponse",
565 reason: "embedded message failed validation",
566 cause: err,
567 }
568 }
569 }
570
571 case *CheckResponse_OkResponse:
572 if v == nil {
573 err := CheckResponseValidationError{
574 field: "HttpResponse",
575 reason: "oneof value cannot be a typed-nil",
576 }
577 if !all {
578 return err
579 }
580 errors = append(errors, err)
581 }
582
583 if all {
584 switch v := interface{}(m.GetOkResponse()).(type) {
585 case interface{ ValidateAll() error }:
586 if err := v.ValidateAll(); err != nil {
587 errors = append(errors, CheckResponseValidationError{
588 field: "OkResponse",
589 reason: "embedded message failed validation",
590 cause: err,
591 })
592 }
593 case interface{ Validate() error }:
594 if err := v.Validate(); err != nil {
595 errors = append(errors, CheckResponseValidationError{
596 field: "OkResponse",
597 reason: "embedded message failed validation",
598 cause: err,
599 })
600 }
601 }
602 } else if v, ok := interface{}(m.GetOkResponse()).(interface{ Validate() error }); ok {
603 if err := v.Validate(); err != nil {
604 return CheckResponseValidationError{
605 field: "OkResponse",
606 reason: "embedded message failed validation",
607 cause: err,
608 }
609 }
610 }
611
612 default:
613 _ = v
614 }
615
616 if len(errors) > 0 {
617 return CheckResponseMultiError(errors)
618 }
619
620 return nil
621 }
622
623
624
625
626 type CheckResponseMultiError []error
627
628
629 func (m CheckResponseMultiError) Error() string {
630 var msgs []string
631 for _, err := range m {
632 msgs = append(msgs, err.Error())
633 }
634 return strings.Join(msgs, "; ")
635 }
636
637
638 func (m CheckResponseMultiError) AllErrors() []error { return m }
639
640
641
642 type CheckResponseValidationError struct {
643 field string
644 reason string
645 cause error
646 key bool
647 }
648
649
650 func (e CheckResponseValidationError) Field() string { return e.field }
651
652
653 func (e CheckResponseValidationError) Reason() string { return e.reason }
654
655
656 func (e CheckResponseValidationError) Cause() error { return e.cause }
657
658
659 func (e CheckResponseValidationError) Key() bool { return e.key }
660
661
662 func (e CheckResponseValidationError) ErrorName() string { return "CheckResponseValidationError" }
663
664
665 func (e CheckResponseValidationError) Error() string {
666 cause := ""
667 if e.cause != nil {
668 cause = fmt.Sprintf(" | caused by: %v", e.cause)
669 }
670
671 key := ""
672 if e.key {
673 key = "key for "
674 }
675
676 return fmt.Sprintf(
677 "invalid %sCheckResponse.%s: %s%s",
678 key,
679 e.field,
680 e.reason,
681 cause)
682 }
683
684 var _ error = CheckResponseValidationError{}
685
686 var _ interface {
687 Field() string
688 Reason() string
689 Key() bool
690 Cause() error
691 ErrorName() string
692 } = CheckResponseValidationError{}
693
View as plain text