Debian Codegraph @

envoy/config/core/v3/resolver.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/resolver.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 DnsResolverOptions 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 *DnsResolverOptions) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on DnsResolverOptions 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 // DnsResolverOptionsMultiError, or nil if none found.
50 func (m *DnsResolverOptions) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *DnsResolverOptions) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 // no validation rules for UseTcpForDnsLookups
62
63 // no validation rules for NoDefaultSearchDomain
64
65 if len(errors) > 0 {
66 return DnsResolverOptionsMultiError(errors)
67 }
68
69 return nil
70 }
71
72 // DnsResolverOptionsMultiError is an error wrapping multiple validation errors
73 // returned by DnsResolverOptions.ValidateAll() if the designated constraints
74 // aren't met.
75 type DnsResolverOptionsMultiError []error
76
77 // Error returns a concatenation of all the error messages it wraps.
78 func (m DnsResolverOptionsMultiError) Error() string {
79 var msgs []string
80 for _, err := range m {
81 msgs = append(msgs, err.Error())
82 }
83 return strings.Join(msgs, "; ")
84 }
85
86 // AllErrors returns a list of validation violation errors.
87 func (m DnsResolverOptionsMultiError) AllErrors() []error { return m }
88
89 // DnsResolverOptionsValidationError is the validation error returned by
90 // DnsResolverOptions.Validate if the designated constraints aren't met.
91 type DnsResolverOptionsValidationError struct {
92 field string
93 reason string
94 cause error
95 key bool
96 }
97
98 // Field function returns field value.
99 func (e DnsResolverOptionsValidationError) Field() string { return e.field }
100
101 // Reason function returns reason value.
102 func (e DnsResolverOptionsValidationError) Reason() string { return e.reason }
103
104 // Cause function returns cause value.
105 func (e DnsResolverOptionsValidationError) Cause() error { return e.cause }
106
107 // Key function returns key value.
108 func (e DnsResolverOptionsValidationError) Key() bool { return e.key }
109
110 // ErrorName returns error name.
111 func (e DnsResolverOptionsValidationError) ErrorName() string {
112 return "DnsResolverOptionsValidationError"
113 }
114
115 // Error satisfies the builtin error interface
116 func (e DnsResolverOptionsValidationError) Error() string {
117 cause := ""
118 if e.cause != nil {
119 cause = fmt.Sprintf(" | caused by: %v", e.cause)
120 }
121
122 key := ""
123 if e.key {
124 key = "key for "
125 }
126
127 return fmt.Sprintf(
128 "invalid %sDnsResolverOptions.%s: %s%s",
129 key,
130 e.field,
131 e.reason,
132 cause)
133 }
134
135 var _ error = DnsResolverOptionsValidationError{}
136
137 var _ interface {
138 Field() string
139 Reason() string
140 Key() bool
141 Cause() error
142 ErrorName() string
143 } = DnsResolverOptionsValidationError{}
144
145 // Validate checks the field values on DnsResolutionConfig with the rules
146 // defined in the proto definition for this message. If any rules are
147 // violated, the first error encountered is returned, or nil if there are no violations.
148 func (m *DnsResolutionConfig) Validate() error {
149 return m.validate(false)
150 }
151
152 // ValidateAll checks the field values on DnsResolutionConfig with the rules
153 // defined in the proto definition for this message. If any rules are
154 // violated, the result is a list of violation errors wrapped in
155 // DnsResolutionConfigMultiError, or nil if none found.
156 func (m *DnsResolutionConfig) ValidateAll() error {
157 return m.validate(true)
158 }
159
160 func (m *DnsResolutionConfig) validate(all bool) error {
161 if m == nil {
162 return nil
163 }
164
165 var errors []error
166
167 if len(m.GetResolvers()) < 1 {
168 err := DnsResolutionConfigValidationError{
169 field: "Resolvers",
170 reason: "value must contain at least 1 item(s)",
171 }
172 if !all {
173 return err
174 }
175 errors = append(errors, err)
176 }
177
178 for idx, item := range m.GetResolvers() {
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, DnsResolutionConfigValidationError{
186 field: fmt.Sprintf("Resolvers[%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, DnsResolutionConfigValidationError{
194 field: fmt.Sprintf("Resolvers[%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 DnsResolutionConfigValidationError{
203 field: fmt.Sprintf("Resolvers[%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.GetDnsResolverOptions()).(type) {
214 case interface{ ValidateAll() error }:
215 if err := v.ValidateAll(); err != nil {
216 errors = append(errors, DnsResolutionConfigValidationError{
217 field: "DnsResolverOptions",
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, DnsResolutionConfigValidationError{
225 field: "DnsResolverOptions",
226 reason: "embedded message failed validation",
227 cause: err,
228 })
229 }
230 }
231 } else if v, ok := interface{}(m.GetDnsResolverOptions()).(interface{ Validate() error }); ok {
232 if err := v.Validate(); err != nil {
233 return DnsResolutionConfigValidationError{
234 field: "DnsResolverOptions",
235 reason: "embedded message failed validation",
236 cause: err,
237 }
238 }
239 }
240
241 if len(errors) > 0 {
242 return DnsResolutionConfigMultiError(errors)
243 }
244
245 return nil
246 }
247
248 // DnsResolutionConfigMultiError is an error wrapping multiple validation
249 // errors returned by DnsResolutionConfig.ValidateAll() if the designated
250 // constraints aren't met.
251 type DnsResolutionConfigMultiError []error
252
253 // Error returns a concatenation of all the error messages it wraps.
254 func (m DnsResolutionConfigMultiError) Error() string {
255 var msgs []string
256 for _, err := range m {
257 msgs = append(msgs, err.Error())
258 }
259 return strings.Join(msgs, "; ")
260 }
261
262 // AllErrors returns a list of validation violation errors.
263 func (m DnsResolutionConfigMultiError) AllErrors() []error { return m }
264
265 // DnsResolutionConfigValidationError is the validation error returned by
266 // DnsResolutionConfig.Validate if the designated constraints aren't met.
267 type DnsResolutionConfigValidationError struct {
268 field string
269 reason string
270 cause error
271 key bool
272 }
273
274 // Field function returns field value.
275 func (e DnsResolutionConfigValidationError) Field() string { return e.field }
276
277 // Reason function returns reason value.
278 func (e DnsResolutionConfigValidationError) Reason() string { return e.reason }
279
280 // Cause function returns cause value.
281 func (e DnsResolutionConfigValidationError) Cause() error { return e.cause }
282
283 // Key function returns key value.
284 func (e DnsResolutionConfigValidationError) Key() bool { return e.key }
285
286 // ErrorName returns error name.
287 func (e DnsResolutionConfigValidationError) ErrorName() string {
288 return "DnsResolutionConfigValidationError"
289 }
290
291 // Error satisfies the builtin error interface
292 func (e DnsResolutionConfigValidationError) Error() string {
293 cause := ""
294 if e.cause != nil {
295 cause = fmt.Sprintf(" | caused by: %v", e.cause)
296 }
297
298 key := ""
299 if e.key {
300 key = "key for "
301 }
302
303 return fmt.Sprintf(
304 "invalid %sDnsResolutionConfig.%s: %s%s",
305 key,
306 e.field,
307 e.reason,
308 cause)
309 }
310
311 var _ error = DnsResolutionConfigValidationError{}
312
313 var _ interface {
314 Field() string
315 Reason() string
316 Key() bool
317 Cause() error
318 ErrorName() string
319 } = DnsResolutionConfigValidationError{}