Debian Codegraph @

envoy/extensions/common/tap/v3/common.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/extensions/common/tap/v3/common.proto
4
5 package tapv3
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 CommonExtensionConfig 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 *CommonExtensionConfig) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on CommonExtensionConfig 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 // CommonExtensionConfigMultiError, or nil if none found.
50 func (m *CommonExtensionConfig) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *CommonExtensionConfig) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 oneofConfigTypePresent := false
62 switch v := m.ConfigType.(type) {
63 case *CommonExtensionConfig_AdminConfig:
64 if v == nil {
65 err := CommonExtensionConfigValidationError{
66 field: "ConfigType",
67 reason: "oneof value cannot be a typed-nil",
68 }
69 if !all {
70 return err
71 }
72 errors = append(errors, err)
73 }
74 oneofConfigTypePresent = true
75
76 if all {
77 switch v := interface{}(m.GetAdminConfig()).(type) {
78 case interface{ ValidateAll() error }:
79 if err := v.ValidateAll(); err != nil {
80 errors = append(errors, CommonExtensionConfigValidationError{
81 field: "AdminConfig",
82 reason: "embedded message failed validation",
83 cause: err,
84 })
85 }
86 case interface{ Validate() error }:
87 if err := v.Validate(); err != nil {
88 errors = append(errors, CommonExtensionConfigValidationError{
89 field: "AdminConfig",
90 reason: "embedded message failed validation",
91 cause: err,
92 })
93 }
94 }
95 } else if v, ok := interface{}(m.GetAdminConfig()).(interface{ Validate() error }); ok {
96 if err := v.Validate(); err != nil {
97 return CommonExtensionConfigValidationError{
98 field: "AdminConfig",
99 reason: "embedded message failed validation",
100 cause: err,
101 }
102 }
103 }
104
105 case *CommonExtensionConfig_StaticConfig:
106 if v == nil {
107 err := CommonExtensionConfigValidationError{
108 field: "ConfigType",
109 reason: "oneof value cannot be a typed-nil",
110 }
111 if !all {
112 return err
113 }
114 errors = append(errors, err)
115 }
116 oneofConfigTypePresent = true
117
118 if all {
119 switch v := interface{}(m.GetStaticConfig()).(type) {
120 case interface{ ValidateAll() error }:
121 if err := v.ValidateAll(); err != nil {
122 errors = append(errors, CommonExtensionConfigValidationError{
123 field: "StaticConfig",
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, CommonExtensionConfigValidationError{
131 field: "StaticConfig",
132 reason: "embedded message failed validation",
133 cause: err,
134 })
135 }
136 }
137 } else if v, ok := interface{}(m.GetStaticConfig()).(interface{ Validate() error }); ok {
138 if err := v.Validate(); err != nil {
139 return CommonExtensionConfigValidationError{
140 field: "StaticConfig",
141 reason: "embedded message failed validation",
142 cause: err,
143 }
144 }
145 }
146
147 default:
148 _ = v // ensures v is used
149 }
150 if !oneofConfigTypePresent {
151 err := CommonExtensionConfigValidationError{
152 field: "ConfigType",
153 reason: "value is required",
154 }
155 if !all {
156 return err
157 }
158 errors = append(errors, err)
159 }
160
161 if len(errors) > 0 {
162 return CommonExtensionConfigMultiError(errors)
163 }
164
165 return nil
166 }
167
168 // CommonExtensionConfigMultiError is an error wrapping multiple validation
169 // errors returned by CommonExtensionConfig.ValidateAll() if the designated
170 // constraints aren't met.
171 type CommonExtensionConfigMultiError []error
172
173 // Error returns a concatenation of all the error messages it wraps.
174 func (m CommonExtensionConfigMultiError) Error() string {
175 var msgs []string
176 for _, err := range m {
177 msgs = append(msgs, err.Error())
178 }
179 return strings.Join(msgs, "; ")
180 }
181
182 // AllErrors returns a list of validation violation errors.
183 func (m CommonExtensionConfigMultiError) AllErrors() []error { return m }
184
185 // CommonExtensionConfigValidationError is the validation error returned by
186 // CommonExtensionConfig.Validate if the designated constraints aren't met.
187 type CommonExtensionConfigValidationError struct {
188 field string
189 reason string
190 cause error
191 key bool
192 }
193
194 // Field function returns field value.
195 func (e CommonExtensionConfigValidationError) Field() string { return e.field }
196
197 // Reason function returns reason value.
198 func (e CommonExtensionConfigValidationError) Reason() string { return e.reason }
199
200 // Cause function returns cause value.
201 func (e CommonExtensionConfigValidationError) Cause() error { return e.cause }
202
203 // Key function returns key value.
204 func (e CommonExtensionConfigValidationError) Key() bool { return e.key }
205
206 // ErrorName returns error name.
207 func (e CommonExtensionConfigValidationError) ErrorName() string {
208 return "CommonExtensionConfigValidationError"
209 }
210
211 // Error satisfies the builtin error interface
212 func (e CommonExtensionConfigValidationError) Error() string {
213 cause := ""
214 if e.cause != nil {
215 cause = fmt.Sprintf(" | caused by: %v", e.cause)
216 }
217
218 key := ""
219 if e.key {
220 key = "key for "
221 }
222
223 return fmt.Sprintf(
224 "invalid %sCommonExtensionConfig.%s: %s%s",
225 key,
226 e.field,
227 e.reason,
228 cause)
229 }
230
231 var _ error = CommonExtensionConfigValidationError{}
232
233 var _ interface {
234 Field() string
235 Reason() string
236 Key() bool
237 Cause() error
238 ErrorName() string
239 } = CommonExtensionConfigValidationError{}
240
241 // Validate checks the field values on AdminConfig with the rules defined in
242 // the proto definition for this message. If any rules are violated, the first
243 // error encountered is returned, or nil if there are no violations.
244 func (m *AdminConfig) Validate() error {
245 return m.validate(false)
246 }
247
248 // ValidateAll checks the field values on AdminConfig with the rules defined in
249 // the proto definition for this message. If any rules are violated, the
250 // result is a list of violation errors wrapped in AdminConfigMultiError, or
251 // nil if none found.
252 func (m *AdminConfig) ValidateAll() error {
253 return m.validate(true)
254 }
255
256 func (m *AdminConfig) validate(all bool) error {
257 if m == nil {
258 return nil
259 }
260
261 var errors []error
262
263 if utf8.RuneCountInString(m.GetConfigId()) < 1 {
264 err := AdminConfigValidationError{
265 field: "ConfigId",
266 reason: "value length must be at least 1 runes",
267 }
268 if !all {
269 return err
270 }
271 errors = append(errors, err)
272 }
273
274 if len(errors) > 0 {
275 return AdminConfigMultiError(errors)
276 }
277
278 return nil
279 }
280
281 // AdminConfigMultiError is an error wrapping multiple validation errors
282 // returned by AdminConfig.ValidateAll() if the designated constraints aren't met.
283 type AdminConfigMultiError []error
284
285 // Error returns a concatenation of all the error messages it wraps.
286 func (m AdminConfigMultiError) Error() string {
287 var msgs []string
288 for _, err := range m {
289 msgs = append(msgs, err.Error())
290 }
291 return strings.Join(msgs, "; ")
292 }
293
294 // AllErrors returns a list of validation violation errors.
295 func (m AdminConfigMultiError) AllErrors() []error { return m }
296
297 // AdminConfigValidationError is the validation error returned by
298 // AdminConfig.Validate if the designated constraints aren't met.
299 type AdminConfigValidationError struct {
300 field string
301 reason string
302 cause error
303 key bool
304 }
305
306 // Field function returns field value.
307 func (e AdminConfigValidationError) Field() string { return e.field }
308
309 // Reason function returns reason value.
310 func (e AdminConfigValidationError) Reason() string { return e.reason }
311
312 // Cause function returns cause value.
313 func (e AdminConfigValidationError) Cause() error { return e.cause }
314
315 // Key function returns key value.
316 func (e AdminConfigValidationError) Key() bool { return e.key }
317
318 // ErrorName returns error name.
319 func (e AdminConfigValidationError) ErrorName() string { return "AdminConfigValidationError" }
320
321 // Error satisfies the builtin error interface
322 func (e AdminConfigValidationError) Error() string {
323 cause := ""
324 if e.cause != nil {
325 cause = fmt.Sprintf(" | caused by: %v", e.cause)
326 }
327
328 key := ""
329 if e.key {
330 key = "key for "
331 }
332
333 return fmt.Sprintf(
334 "invalid %sAdminConfig.%s: %s%s",
335 key,
336 e.field,
337 e.reason,
338 cause)
339 }
340
341 var _ error = AdminConfigValidationError{}
342
343 var _ interface {
344 Field() string
345 Reason() string
346 Key() bool
347 Cause() error
348 ErrorName() string
349 } = AdminConfigValidationError{}