Debian Codegraph @

envoy/config/core/v3/substitution_format_string.pb.validate.go

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