Debian Codegraph @

go/xds/type/v3/cel.pb.validate.go

raw symbols SCIP
1 // Code generated by protoc-gen-validate. DO NOT EDIT.
2 // source: xds/type/v3/cel.proto
3
4 package v3
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 // ensure the imports are used
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 // Validate checks the field values on CelExpression with the rules defined in
39 // the proto definition for this message. If any rules are violated, the first
40 // error encountered is returned, or nil if there are no violations.
41 func (m *CelExpression) Validate() error {
42 return m.validate(false)
43 }
44
45 // ValidateAll checks the field values on CelExpression with the rules defined
46 // in the proto definition for this message. If any rules are violated, the
47 // result is a list of violation errors wrapped in CelExpressionMultiError, or
48 // nil if none found.
49 func (m *CelExpression) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *CelExpression) 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.GetCelExprParsed()).(type) {
62 case interface{ ValidateAll() error }:
63 if err := v.ValidateAll(); err != nil {
64 errors = append(errors, CelExpressionValidationError{
65 field: "CelExprParsed",
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, CelExpressionValidationError{
73 field: "CelExprParsed",
74 reason: "embedded message failed validation",
75 cause: err,
76 })
77 }
78 }
79 } else if v, ok := interface{}(m.GetCelExprParsed()).(interface{ Validate() error }); ok {
80 if err := v.Validate(); err != nil {
81 return CelExpressionValidationError{
82 field: "CelExprParsed",
83 reason: "embedded message failed validation",
84 cause: err,
85 }
86 }
87 }
88
89 if all {
90 switch v := interface{}(m.GetCelExprChecked()).(type) {
91 case interface{ ValidateAll() error }:
92 if err := v.ValidateAll(); err != nil {
93 errors = append(errors, CelExpressionValidationError{
94 field: "CelExprChecked",
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, CelExpressionValidationError{
102 field: "CelExprChecked",
103 reason: "embedded message failed validation",
104 cause: err,
105 })
106 }
107 }
108 } else if v, ok := interface{}(m.GetCelExprChecked()).(interface{ Validate() error }); ok {
109 if err := v.Validate(); err != nil {
110 return CelExpressionValidationError{
111 field: "CelExprChecked",
112 reason: "embedded message failed validation",
113 cause: err,
114 }
115 }
116 }
117
118 // no validation rules for CelExprString
119
120 switch v := m.ExprSpecifier.(type) {
121 case *CelExpression_ParsedExpr:
122 if v == nil {
123 err := CelExpressionValidationError{
124 field: "ExprSpecifier",
125 reason: "oneof value cannot be a typed-nil",
126 }
127 if !all {
128 return err
129 }
130 errors = append(errors, err)
131 }
132
133 if all {
134 switch v := interface{}(m.GetParsedExpr()).(type) {
135 case interface{ ValidateAll() error }:
136 if err := v.ValidateAll(); err != nil {
137 errors = append(errors, CelExpressionValidationError{
138 field: "ParsedExpr",
139 reason: "embedded message failed validation",
140 cause: err,
141 })
142 }
143 case interface{ Validate() error }:
144 if err := v.Validate(); err != nil {
145 errors = append(errors, CelExpressionValidationError{
146 field: "ParsedExpr",
147 reason: "embedded message failed validation",
148 cause: err,
149 })
150 }
151 }
152 } else if v, ok := interface{}(m.GetParsedExpr()).(interface{ Validate() error }); ok {
153 if err := v.Validate(); err != nil {
154 return CelExpressionValidationError{
155 field: "ParsedExpr",
156 reason: "embedded message failed validation",
157 cause: err,
158 }
159 }
160 }
161
162 case *CelExpression_CheckedExpr:
163 if v == nil {
164 err := CelExpressionValidationError{
165 field: "ExprSpecifier",
166 reason: "oneof value cannot be a typed-nil",
167 }
168 if !all {
169 return err
170 }
171 errors = append(errors, err)
172 }
173
174 if all {
175 switch v := interface{}(m.GetCheckedExpr()).(type) {
176 case interface{ ValidateAll() error }:
177 if err := v.ValidateAll(); err != nil {
178 errors = append(errors, CelExpressionValidationError{
179 field: "CheckedExpr",
180 reason: "embedded message failed validation",
181 cause: err,
182 })
183 }
184 case interface{ Validate() error }:
185 if err := v.Validate(); err != nil {
186 errors = append(errors, CelExpressionValidationError{
187 field: "CheckedExpr",
188 reason: "embedded message failed validation",
189 cause: err,
190 })
191 }
192 }
193 } else if v, ok := interface{}(m.GetCheckedExpr()).(interface{ Validate() error }); ok {
194 if err := v.Validate(); err != nil {
195 return CelExpressionValidationError{
196 field: "CheckedExpr",
197 reason: "embedded message failed validation",
198 cause: err,
199 }
200 }
201 }
202
203 default:
204 _ = v // ensures v is used
205 }
206
207 if len(errors) > 0 {
208 return CelExpressionMultiError(errors)
209 }
210
211 return nil
212 }
213
214 // CelExpressionMultiError is an error wrapping multiple validation errors
215 // returned by CelExpression.ValidateAll() if the designated constraints
216 // aren't met.
217 type CelExpressionMultiError []error
218
219 // Error returns a concatenation of all the error messages it wraps.
220 func (m CelExpressionMultiError) Error() string {
221 msgs := make([]string, 0, len(m))
222 for _, err := range m {
223 msgs = append(msgs, err.Error())
224 }
225 return strings.Join(msgs, "; ")
226 }
227
228 // AllErrors returns a list of validation violation errors.
229 func (m CelExpressionMultiError) AllErrors() []error { return m }
230
231 // CelExpressionValidationError is the validation error returned by
232 // CelExpression.Validate if the designated constraints aren't met.
233 type CelExpressionValidationError struct {
234 field string
235 reason string
236 cause error
237 key bool
238 }
239
240 // Field function returns field value.
241 func (e CelExpressionValidationError) Field() string { return e.field }
242
243 // Reason function returns reason value.
244 func (e CelExpressionValidationError) Reason() string { return e.reason }
245
246 // Cause function returns cause value.
247 func (e CelExpressionValidationError) Cause() error { return e.cause }
248
249 // Key function returns key value.
250 func (e CelExpressionValidationError) Key() bool { return e.key }
251
252 // ErrorName returns error name.
253 func (e CelExpressionValidationError) ErrorName() string { return "CelExpressionValidationError" }
254
255 // Error satisfies the builtin error interface
256 func (e CelExpressionValidationError) Error() string {
257 cause := ""
258 if e.cause != nil {
259 cause = fmt.Sprintf(" | caused by: %v", e.cause)
260 }
261
262 key := ""
263 if e.key {
264 key = "key for "
265 }
266
267 return fmt.Sprintf(
268 "invalid %sCelExpression.%s: %s%s",
269 key,
270 e.field,
271 e.reason,
272 cause)
273 }
274
275 var _ error = CelExpressionValidationError{}
276
277 var _ interface {
278 Field() string
279 Reason() string
280 Key() bool
281 Cause() error
282 ErrorName() string
283 } = CelExpressionValidationError{}
284
285 // Validate checks the field values on CelExtractString with the rules defined
286 // in the proto definition for this message. If any rules are violated, the
287 // first error encountered is returned, or nil if there are no violations.
288 func (m *CelExtractString) Validate() error {
289 return m.validate(false)
290 }
291
292 // ValidateAll checks the field values on CelExtractString with the rules
293 // defined in the proto definition for this message. If any rules are
294 // violated, the result is a list of violation errors wrapped in
295 // CelExtractStringMultiError, or nil if none found.
296 func (m *CelExtractString) ValidateAll() error {
297 return m.validate(true)
298 }
299
300 func (m *CelExtractString) validate(all bool) error {
301 if m == nil {
302 return nil
303 }
304
305 var errors []error
306
307 if m.GetExprExtract() == nil {
308 err := CelExtractStringValidationError{
309 field: "ExprExtract",
310 reason: "value is required",
311 }
312 if !all {
313 return err
314 }
315 errors = append(errors, err)
316 }
317
318 if all {
319 switch v := interface{}(m.GetExprExtract()).(type) {
320 case interface{ ValidateAll() error }:
321 if err := v.ValidateAll(); err != nil {
322 errors = append(errors, CelExtractStringValidationError{
323 field: "ExprExtract",
324 reason: "embedded message failed validation",
325 cause: err,
326 })
327 }
328 case interface{ Validate() error }:
329 if err := v.Validate(); err != nil {
330 errors = append(errors, CelExtractStringValidationError{
331 field: "ExprExtract",
332 reason: "embedded message failed validation",
333 cause: err,
334 })
335 }
336 }
337 } else if v, ok := interface{}(m.GetExprExtract()).(interface{ Validate() error }); ok {
338 if err := v.Validate(); err != nil {
339 return CelExtractStringValidationError{
340 field: "ExprExtract",
341 reason: "embedded message failed validation",
342 cause: err,
343 }
344 }
345 }
346
347 if all {
348 switch v := interface{}(m.GetDefaultValue()).(type) {
349 case interface{ ValidateAll() error }:
350 if err := v.ValidateAll(); err != nil {
351 errors = append(errors, CelExtractStringValidationError{
352 field: "DefaultValue",
353 reason: "embedded message failed validation",
354 cause: err,
355 })
356 }
357 case interface{ Validate() error }:
358 if err := v.Validate(); err != nil {
359 errors = append(errors, CelExtractStringValidationError{
360 field: "DefaultValue",
361 reason: "embedded message failed validation",
362 cause: err,
363 })
364 }
365 }
366 } else if v, ok := interface{}(m.GetDefaultValue()).(interface{ Validate() error }); ok {
367 if err := v.Validate(); err != nil {
368 return CelExtractStringValidationError{
369 field: "DefaultValue",
370 reason: "embedded message failed validation",
371 cause: err,
372 }
373 }
374 }
375
376 if len(errors) > 0 {
377 return CelExtractStringMultiError(errors)
378 }
379
380 return nil
381 }
382
383 // CelExtractStringMultiError is an error wrapping multiple validation errors
384 // returned by CelExtractString.ValidateAll() if the designated constraints
385 // aren't met.
386 type CelExtractStringMultiError []error
387
388 // Error returns a concatenation of all the error messages it wraps.
389 func (m CelExtractStringMultiError) Error() string {
390 msgs := make([]string, 0, len(m))
391 for _, err := range m {
392 msgs = append(msgs, err.Error())
393 }
394 return strings.Join(msgs, "; ")
395 }
396
397 // AllErrors returns a list of validation violation errors.
398 func (m CelExtractStringMultiError) AllErrors() []error { return m }
399
400 // CelExtractStringValidationError is the validation error returned by
401 // CelExtractString.Validate if the designated constraints aren't met.
402 type CelExtractStringValidationError struct {
403 field string
404 reason string
405 cause error
406 key bool
407 }
408
409 // Field function returns field value.
410 func (e CelExtractStringValidationError) Field() string { return e.field }
411
412 // Reason function returns reason value.
413 func (e CelExtractStringValidationError) Reason() string { return e.reason }
414
415 // Cause function returns cause value.
416 func (e CelExtractStringValidationError) Cause() error { return e.cause }
417
418 // Key function returns key value.
419 func (e CelExtractStringValidationError) Key() bool { return e.key }
420
421 // ErrorName returns error name.
422 func (e CelExtractStringValidationError) ErrorName() string { return "CelExtractStringValidationError" }
423
424 // Error satisfies the builtin error interface
425 func (e CelExtractStringValidationError) Error() string {
426 cause := ""
427 if e.cause != nil {
428 cause = fmt.Sprintf(" | caused by: %v", e.cause)
429 }
430
431 key := ""
432 if e.key {
433 key = "key for "
434 }
435
436 return fmt.Sprintf(
437 "invalid %sCelExtractString.%s: %s%s",
438 key,
439 e.field,
440 e.reason,
441 cause)
442 }
443
444 var _ error = CelExtractStringValidationError{}
445
446 var _ interface {
447 Field() string
448 Reason() string
449 Key() bool
450 Cause() error
451 ErrorName() string
452 } = CelExtractStringValidationError{}