Debian Codegraph @

envoy/config/trace/v3/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/v3/http_tracer.proto
4
5 package tracev3
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 utf8.RuneCountInString(m.GetName()) < 1 {
189 err := Tracing_HttpValidationError{
190 field: "Name",
191 reason: "value length must be at least 1 runes",
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_TypedConfig:
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.GetTypedConfig()).(type) {
214 case interface{ ValidateAll() error }:
215 if err := v.ValidateAll(); err != nil {
216 errors = append(errors, Tracing_HttpValidationError{
217 field: "TypedConfig",
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: "TypedConfig",
226 reason: "embedded message failed validation",
227 cause: err,
228 })
229 }
230 }
231 } else if v, ok := interface{}(m.GetTypedConfig()).(interface{ Validate() error }); ok {
232 if err := v.Validate(); err != nil {
233 return Tracing_HttpValidationError{
234 field: "TypedConfig",
235 reason: "embedded message failed validation",
236 cause: err,
237 }
238 }
239 }
240
241 default:
242 _ = v // ensures v is used
243 }
244
245 if len(errors) > 0 {
246 return Tracing_HttpMultiError(errors)
247 }
248
249 return nil
250 }
251
252 // Tracing_HttpMultiError is an error wrapping multiple validation errors
253 // returned by Tracing_Http.ValidateAll() if the designated constraints aren't met.
254 type Tracing_HttpMultiError []error
255
256 // Error returns a concatenation of all the error messages it wraps.
257 func (m Tracing_HttpMultiError) Error() string {
258 var msgs []string
259 for _, err := range m {
260 msgs = append(msgs, err.Error())
261 }
262 return strings.Join(msgs, "; ")
263 }
264
265 // AllErrors returns a list of validation violation errors.
266 func (m Tracing_HttpMultiError) AllErrors() []error { return m }
267
268 // Tracing_HttpValidationError is the validation error returned by
269 // Tracing_Http.Validate if the designated constraints aren't met.
270 type Tracing_HttpValidationError struct {
271 field string
272 reason string
273 cause error
274 key bool
275 }
276
277 // Field function returns field value.
278 func (e Tracing_HttpValidationError) Field() string { return e.field }
279
280 // Reason function returns reason value.
281 func (e Tracing_HttpValidationError) Reason() string { return e.reason }
282
283 // Cause function returns cause value.
284 func (e Tracing_HttpValidationError) Cause() error { return e.cause }
285
286 // Key function returns key value.
287 func (e Tracing_HttpValidationError) Key() bool { return e.key }
288
289 // ErrorName returns error name.
290 func (e Tracing_HttpValidationError) ErrorName() string { return "Tracing_HttpValidationError" }
291
292 // Error satisfies the builtin error interface
293 func (e Tracing_HttpValidationError) Error() string {
294 cause := ""
295 if e.cause != nil {
296 cause = fmt.Sprintf(" | caused by: %v", e.cause)
297 }
298
299 key := ""
300 if e.key {
301 key = "key for "
302 }
303
304 return fmt.Sprintf(
305 "invalid %sTracing_Http.%s: %s%s",
306 key,
307 e.field,
308 e.reason,
309 cause)
310 }
311
312 var _ error = Tracing_HttpValidationError{}
313
314 var _ interface {
315 Field() string
316 Reason() string
317 Key() bool
318 Cause() error
319 ErrorName() string
320 } = Tracing_HttpValidationError{}