Debian Codegraph @

go/xds/core/v3/collection_entry.pb.validate.go

raw symbols SCIP
1 // Code generated by protoc-gen-validate. DO NOT EDIT.
2 // source: xds/core/v3/collection_entry.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 CollectionEntry with the rules defined
39 // in the proto definition for this message. If any rules are violated, the
40 // first error encountered is returned, or nil if there are no violations.
41 func (m *CollectionEntry) Validate() error {
42 return m.validate(false)
43 }
44
45 // ValidateAll checks the field values on CollectionEntry with the rules
46 // defined in the proto definition for this message. If any rules are
47 // violated, the result is a list of violation errors wrapped in
48 // CollectionEntryMultiError, or nil if none found.
49 func (m *CollectionEntry) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *CollectionEntry) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 oneofResourceSpecifierPresent := false
61 switch v := m.ResourceSpecifier.(type) {
62 case *CollectionEntry_Locator:
63 if v == nil {
64 err := CollectionEntryValidationError{
65 field: "ResourceSpecifier",
66 reason: "oneof value cannot be a typed-nil",
67 }
68 if !all {
69 return err
70 }
71 errors = append(errors, err)
72 }
73 oneofResourceSpecifierPresent = true
74
75 if all {
76 switch v := interface{}(m.GetLocator()).(type) {
77 case interface{ ValidateAll() error }:
78 if err := v.ValidateAll(); err != nil {
79 errors = append(errors, CollectionEntryValidationError{
80 field: "Locator",
81 reason: "embedded message failed validation",
82 cause: err,
83 })
84 }
85 case interface{ Validate() error }:
86 if err := v.Validate(); err != nil {
87 errors = append(errors, CollectionEntryValidationError{
88 field: "Locator",
89 reason: "embedded message failed validation",
90 cause: err,
91 })
92 }
93 }
94 } else if v, ok := interface{}(m.GetLocator()).(interface{ Validate() error }); ok {
95 if err := v.Validate(); err != nil {
96 return CollectionEntryValidationError{
97 field: "Locator",
98 reason: "embedded message failed validation",
99 cause: err,
100 }
101 }
102 }
103
104 case *CollectionEntry_InlineEntry_:
105 if v == nil {
106 err := CollectionEntryValidationError{
107 field: "ResourceSpecifier",
108 reason: "oneof value cannot be a typed-nil",
109 }
110 if !all {
111 return err
112 }
113 errors = append(errors, err)
114 }
115 oneofResourceSpecifierPresent = true
116
117 if all {
118 switch v := interface{}(m.GetInlineEntry()).(type) {
119 case interface{ ValidateAll() error }:
120 if err := v.ValidateAll(); err != nil {
121 errors = append(errors, CollectionEntryValidationError{
122 field: "InlineEntry",
123 reason: "embedded message failed validation",
124 cause: err,
125 })
126 }
127 case interface{ Validate() error }:
128 if err := v.Validate(); err != nil {
129 errors = append(errors, CollectionEntryValidationError{
130 field: "InlineEntry",
131 reason: "embedded message failed validation",
132 cause: err,
133 })
134 }
135 }
136 } else if v, ok := interface{}(m.GetInlineEntry()).(interface{ Validate() error }); ok {
137 if err := v.Validate(); err != nil {
138 return CollectionEntryValidationError{
139 field: "InlineEntry",
140 reason: "embedded message failed validation",
141 cause: err,
142 }
143 }
144 }
145
146 default:
147 _ = v // ensures v is used
148 }
149 if !oneofResourceSpecifierPresent {
150 err := CollectionEntryValidationError{
151 field: "ResourceSpecifier",
152 reason: "value is required",
153 }
154 if !all {
155 return err
156 }
157 errors = append(errors, err)
158 }
159
160 if len(errors) > 0 {
161 return CollectionEntryMultiError(errors)
162 }
163
164 return nil
165 }
166
167 // CollectionEntryMultiError is an error wrapping multiple validation errors
168 // returned by CollectionEntry.ValidateAll() if the designated constraints
169 // aren't met.
170 type CollectionEntryMultiError []error
171
172 // Error returns a concatenation of all the error messages it wraps.
173 func (m CollectionEntryMultiError) Error() string {
174 msgs := make([]string, 0, len(m))
175 for _, err := range m {
176 msgs = append(msgs, err.Error())
177 }
178 return strings.Join(msgs, "; ")
179 }
180
181 // AllErrors returns a list of validation violation errors.
182 func (m CollectionEntryMultiError) AllErrors() []error { return m }
183
184 // CollectionEntryValidationError is the validation error returned by
185 // CollectionEntry.Validate if the designated constraints aren't met.
186 type CollectionEntryValidationError struct {
187 field string
188 reason string
189 cause error
190 key bool
191 }
192
193 // Field function returns field value.
194 func (e CollectionEntryValidationError) Field() string { return e.field }
195
196 // Reason function returns reason value.
197 func (e CollectionEntryValidationError) Reason() string { return e.reason }
198
199 // Cause function returns cause value.
200 func (e CollectionEntryValidationError) Cause() error { return e.cause }
201
202 // Key function returns key value.
203 func (e CollectionEntryValidationError) Key() bool { return e.key }
204
205 // ErrorName returns error name.
206 func (e CollectionEntryValidationError) ErrorName() string { return "CollectionEntryValidationError" }
207
208 // Error satisfies the builtin error interface
209 func (e CollectionEntryValidationError) Error() string {
210 cause := ""
211 if e.cause != nil {
212 cause = fmt.Sprintf(" | caused by: %v", e.cause)
213 }
214
215 key := ""
216 if e.key {
217 key = "key for "
218 }
219
220 return fmt.Sprintf(
221 "invalid %sCollectionEntry.%s: %s%s",
222 key,
223 e.field,
224 e.reason,
225 cause)
226 }
227
228 var _ error = CollectionEntryValidationError{}
229
230 var _ interface {
231 Field() string
232 Reason() string
233 Key() bool
234 Cause() error
235 ErrorName() string
236 } = CollectionEntryValidationError{}
237
238 // Validate checks the field values on CollectionEntry_InlineEntry with the
239 // rules defined in the proto definition for this message. If any rules are
240 // violated, the first error encountered is returned, or nil if there are no violations.
241 func (m *CollectionEntry_InlineEntry) Validate() error {
242 return m.validate(false)
243 }
244
245 // ValidateAll checks the field values on CollectionEntry_InlineEntry with the
246 // rules defined in the proto definition for this message. If any rules are
247 // violated, the result is a list of violation errors wrapped in
248 // CollectionEntry_InlineEntryMultiError, or nil if none found.
249 func (m *CollectionEntry_InlineEntry) ValidateAll() error {
250 return m.validate(true)
251 }
252
253 func (m *CollectionEntry_InlineEntry) validate(all bool) error {
254 if m == nil {
255 return nil
256 }
257
258 var errors []error
259
260 if !_CollectionEntry_InlineEntry_Name_Pattern.MatchString(m.GetName()) {
261 err := CollectionEntry_InlineEntryValidationError{
262 field: "Name",
263 reason: "value does not match regex pattern \"^[0-9a-zA-Z_\\\\-\\\\.~:]+$\"",
264 }
265 if !all {
266 return err
267 }
268 errors = append(errors, err)
269 }
270
271 // no validation rules for Version
272
273 if all {
274 switch v := interface{}(m.GetResource()).(type) {
275 case interface{ ValidateAll() error }:
276 if err := v.ValidateAll(); err != nil {
277 errors = append(errors, CollectionEntry_InlineEntryValidationError{
278 field: "Resource",
279 reason: "embedded message failed validation",
280 cause: err,
281 })
282 }
283 case interface{ Validate() error }:
284 if err := v.Validate(); err != nil {
285 errors = append(errors, CollectionEntry_InlineEntryValidationError{
286 field: "Resource",
287 reason: "embedded message failed validation",
288 cause: err,
289 })
290 }
291 }
292 } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok {
293 if err := v.Validate(); err != nil {
294 return CollectionEntry_InlineEntryValidationError{
295 field: "Resource",
296 reason: "embedded message failed validation",
297 cause: err,
298 }
299 }
300 }
301
302 if len(errors) > 0 {
303 return CollectionEntry_InlineEntryMultiError(errors)
304 }
305
306 return nil
307 }
308
309 // CollectionEntry_InlineEntryMultiError is an error wrapping multiple
310 // validation errors returned by CollectionEntry_InlineEntry.ValidateAll() if
311 // the designated constraints aren't met.
312 type CollectionEntry_InlineEntryMultiError []error
313
314 // Error returns a concatenation of all the error messages it wraps.
315 func (m CollectionEntry_InlineEntryMultiError) Error() string {
316 msgs := make([]string, 0, len(m))
317 for _, err := range m {
318 msgs = append(msgs, err.Error())
319 }
320 return strings.Join(msgs, "; ")
321 }
322
323 // AllErrors returns a list of validation violation errors.
324 func (m CollectionEntry_InlineEntryMultiError) AllErrors() []error { return m }
325
326 // CollectionEntry_InlineEntryValidationError is the validation error returned
327 // by CollectionEntry_InlineEntry.Validate if the designated constraints
328 // aren't met.
329 type CollectionEntry_InlineEntryValidationError struct {
330 field string
331 reason string
332 cause error
333 key bool
334 }
335
336 // Field function returns field value.
337 func (e CollectionEntry_InlineEntryValidationError) Field() string { return e.field }
338
339 // Reason function returns reason value.
340 func (e CollectionEntry_InlineEntryValidationError) Reason() string { return e.reason }
341
342 // Cause function returns cause value.
343 func (e CollectionEntry_InlineEntryValidationError) Cause() error { return e.cause }
344
345 // Key function returns key value.
346 func (e CollectionEntry_InlineEntryValidationError) Key() bool { return e.key }
347
348 // ErrorName returns error name.
349 func (e CollectionEntry_InlineEntryValidationError) ErrorName() string {
350 return "CollectionEntry_InlineEntryValidationError"
351 }
352
353 // Error satisfies the builtin error interface
354 func (e CollectionEntry_InlineEntryValidationError) Error() string {
355 cause := ""
356 if e.cause != nil {
357 cause = fmt.Sprintf(" | caused by: %v", e.cause)
358 }
359
360 key := ""
361 if e.key {
362 key = "key for "
363 }
364
365 return fmt.Sprintf(
366 "invalid %sCollectionEntry_InlineEntry.%s: %s%s",
367 key,
368 e.field,
369 e.reason,
370 cause)
371 }
372
373 var _ error = CollectionEntry_InlineEntryValidationError{}
374
375 var _ interface {
376 Field() string
377 Reason() string
378 Key() bool
379 Cause() error
380 ErrorName() string
381 } = CollectionEntry_InlineEntryValidationError{}
382
383 var _CollectionEntry_InlineEntry_Name_Pattern = regexp.MustCompile("^[0-9a-zA-Z_\\-\\.~:]+$")