...
1
2
3
4 package envoy_admin_v3
5
6 import (
7 "bytes"
8 "errors"
9 "fmt"
10 "net"
11 "net/mail"
12 "net/url"
13 "regexp"
14 "strings"
15 "time"
16 "unicode/utf8"
17
18 "github.com/golang/protobuf/ptypes"
19 )
20
21
22 var (
23 _ = bytes.MinRead
24 _ = errors.New("")
25 _ = fmt.Print
26 _ = utf8.UTFMax
27 _ = (*regexp.Regexp)(nil)
28 _ = (*strings.Reader)(nil)
29 _ = net.IPv4len
30 _ = time.Duration(0)
31 _ = (*url.URL)(nil)
32 _ = (*mail.Address)(nil)
33 _ = ptypes.DynamicAny{}
34 )
35
36
37
38 func (m *TapRequest) Validate() error {
39 if m == nil {
40 return nil
41 }
42
43 if utf8.RuneCountInString(m.GetConfigId()) < 1 {
44 return TapRequestValidationError{
45 field: "ConfigId",
46 reason: "value length must be at least 1 runes",
47 }
48 }
49
50 if m.GetTapConfig() == nil {
51 return TapRequestValidationError{
52 field: "TapConfig",
53 reason: "value is required",
54 }
55 }
56
57 if v, ok := interface{}(m.GetTapConfig()).(interface{ Validate() error }); ok {
58 if err := v.Validate(); err != nil {
59 return TapRequestValidationError{
60 field: "TapConfig",
61 reason: "embedded message failed validation",
62 cause: err,
63 }
64 }
65 }
66
67 return nil
68 }
69
70
71
72 type TapRequestValidationError struct {
73 field string
74 reason string
75 cause error
76 key bool
77 }
78
79
80 func (e TapRequestValidationError) Field() string { return e.field }
81
82
83 func (e TapRequestValidationError) Reason() string { return e.reason }
84
85
86 func (e TapRequestValidationError) Cause() error { return e.cause }
87
88
89 func (e TapRequestValidationError) Key() bool { return e.key }
90
91
92 func (e TapRequestValidationError) ErrorName() string { return "TapRequestValidationError" }
93
94
95 func (e TapRequestValidationError) Error() string {
96 cause := ""
97 if e.cause != nil {
98 cause = fmt.Sprintf(" | caused by: %v", e.cause)
99 }
100
101 key := ""
102 if e.key {
103 key = "key for "
104 }
105
106 return fmt.Sprintf(
107 "invalid %sTapRequest.%s: %s%s",
108 key,
109 e.field,
110 e.reason,
111 cause)
112 }
113
114 var _ error = TapRequestValidationError{}
115
116 var _ interface {
117 Field() string
118 Reason() string
119 Key() bool
120 Cause() error
121 ErrorName() string
122 } = TapRequestValidationError{}
123
View as plain text