Debian Codegraph @

envoy/config/core/v3/proxy_protocol.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/proxy_protocol.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 ProxyProtocolPassThroughTLVs with the
40 // rules 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 *ProxyProtocolPassThroughTLVs) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on ProxyProtocolPassThroughTLVs with the
47 // rules 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 // ProxyProtocolPassThroughTLVsMultiError, or nil if none found.
50 func (m *ProxyProtocolPassThroughTLVs) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *ProxyProtocolPassThroughTLVs) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 // no validation rules for MatchType
62
63 for idx, item := range m.GetTlvType() {
64 _, _ = idx, item
65
66 if item >= 256 {
67 err := ProxyProtocolPassThroughTLVsValidationError{
68 field: fmt.Sprintf("TlvType[%v]", idx),
69 reason: "value must be less than 256",
70 }
71 if !all {
72 return err
73 }
74 errors = append(errors, err)
75 }
76
77 }
78
79 if len(errors) > 0 {
80 return ProxyProtocolPassThroughTLVsMultiError(errors)
81 }
82
83 return nil
84 }
85
86 // ProxyProtocolPassThroughTLVsMultiError is an error wrapping multiple
87 // validation errors returned by ProxyProtocolPassThroughTLVs.ValidateAll() if
88 // the designated constraints aren't met.
89 type ProxyProtocolPassThroughTLVsMultiError []error
90
91 // Error returns a concatenation of all the error messages it wraps.
92 func (m ProxyProtocolPassThroughTLVsMultiError) Error() string {
93 var msgs []string
94 for _, err := range m {
95 msgs = append(msgs, err.Error())
96 }
97 return strings.Join(msgs, "; ")
98 }
99
100 // AllErrors returns a list of validation violation errors.
101 func (m ProxyProtocolPassThroughTLVsMultiError) AllErrors() []error { return m }
102
103 // ProxyProtocolPassThroughTLVsValidationError is the validation error returned
104 // by ProxyProtocolPassThroughTLVs.Validate if the designated constraints
105 // aren't met.
106 type ProxyProtocolPassThroughTLVsValidationError struct {
107 field string
108 reason string
109 cause error
110 key bool
111 }
112
113 // Field function returns field value.
114 func (e ProxyProtocolPassThroughTLVsValidationError) Field() string { return e.field }
115
116 // Reason function returns reason value.
117 func (e ProxyProtocolPassThroughTLVsValidationError) Reason() string { return e.reason }
118
119 // Cause function returns cause value.
120 func (e ProxyProtocolPassThroughTLVsValidationError) Cause() error { return e.cause }
121
122 // Key function returns key value.
123 func (e ProxyProtocolPassThroughTLVsValidationError) Key() bool { return e.key }
124
125 // ErrorName returns error name.
126 func (e ProxyProtocolPassThroughTLVsValidationError) ErrorName() string {
127 return "ProxyProtocolPassThroughTLVsValidationError"
128 }
129
130 // Error satisfies the builtin error interface
131 func (e ProxyProtocolPassThroughTLVsValidationError) Error() string {
132 cause := ""
133 if e.cause != nil {
134 cause = fmt.Sprintf(" | caused by: %v", e.cause)
135 }
136
137 key := ""
138 if e.key {
139 key = "key for "
140 }
141
142 return fmt.Sprintf(
143 "invalid %sProxyProtocolPassThroughTLVs.%s: %s%s",
144 key,
145 e.field,
146 e.reason,
147 cause)
148 }
149
150 var _ error = ProxyProtocolPassThroughTLVsValidationError{}
151
152 var _ interface {
153 Field() string
154 Reason() string
155 Key() bool
156 Cause() error
157 ErrorName() string
158 } = ProxyProtocolPassThroughTLVsValidationError{}
159
160 // Validate checks the field values on ProxyProtocolConfig with the rules
161 // defined in the proto definition for this message. If any rules are
162 // violated, the first error encountered is returned, or nil if there are no violations.
163 func (m *ProxyProtocolConfig) Validate() error {
164 return m.validate(false)
165 }
166
167 // ValidateAll checks the field values on ProxyProtocolConfig with the rules
168 // defined in the proto definition for this message. If any rules are
169 // violated, the result is a list of violation errors wrapped in
170 // ProxyProtocolConfigMultiError, or nil if none found.
171 func (m *ProxyProtocolConfig) ValidateAll() error {
172 return m.validate(true)
173 }
174
175 func (m *ProxyProtocolConfig) validate(all bool) error {
176 if m == nil {
177 return nil
178 }
179
180 var errors []error
181
182 // no validation rules for Version
183
184 if all {
185 switch v := interface{}(m.GetPassThroughTlvs()).(type) {
186 case interface{ ValidateAll() error }:
187 if err := v.ValidateAll(); err != nil {
188 errors = append(errors, ProxyProtocolConfigValidationError{
189 field: "PassThroughTlvs",
190 reason: "embedded message failed validation",
191 cause: err,
192 })
193 }
194 case interface{ Validate() error }:
195 if err := v.Validate(); err != nil {
196 errors = append(errors, ProxyProtocolConfigValidationError{
197 field: "PassThroughTlvs",
198 reason: "embedded message failed validation",
199 cause: err,
200 })
201 }
202 }
203 } else if v, ok := interface{}(m.GetPassThroughTlvs()).(interface{ Validate() error }); ok {
204 if err := v.Validate(); err != nil {
205 return ProxyProtocolConfigValidationError{
206 field: "PassThroughTlvs",
207 reason: "embedded message failed validation",
208 cause: err,
209 }
210 }
211 }
212
213 if len(errors) > 0 {
214 return ProxyProtocolConfigMultiError(errors)
215 }
216
217 return nil
218 }
219
220 // ProxyProtocolConfigMultiError is an error wrapping multiple validation
221 // errors returned by ProxyProtocolConfig.ValidateAll() if the designated
222 // constraints aren't met.
223 type ProxyProtocolConfigMultiError []error
224
225 // Error returns a concatenation of all the error messages it wraps.
226 func (m ProxyProtocolConfigMultiError) Error() string {
227 var msgs []string
228 for _, err := range m {
229 msgs = append(msgs, err.Error())
230 }
231 return strings.Join(msgs, "; ")
232 }
233
234 // AllErrors returns a list of validation violation errors.
235 func (m ProxyProtocolConfigMultiError) AllErrors() []error { return m }
236
237 // ProxyProtocolConfigValidationError is the validation error returned by
238 // ProxyProtocolConfig.Validate if the designated constraints aren't met.
239 type ProxyProtocolConfigValidationError struct {
240 field string
241 reason string
242 cause error
243 key bool
244 }
245
246 // Field function returns field value.
247 func (e ProxyProtocolConfigValidationError) Field() string { return e.field }
248
249 // Reason function returns reason value.
250 func (e ProxyProtocolConfigValidationError) Reason() string { return e.reason }
251
252 // Cause function returns cause value.
253 func (e ProxyProtocolConfigValidationError) Cause() error { return e.cause }
254
255 // Key function returns key value.
256 func (e ProxyProtocolConfigValidationError) Key() bool { return e.key }
257
258 // ErrorName returns error name.
259 func (e ProxyProtocolConfigValidationError) ErrorName() string {
260 return "ProxyProtocolConfigValidationError"
261 }
262
263 // Error satisfies the builtin error interface
264 func (e ProxyProtocolConfigValidationError) Error() string {
265 cause := ""
266 if e.cause != nil {
267 cause = fmt.Sprintf(" | caused by: %v", e.cause)
268 }
269
270 key := ""
271 if e.key {
272 key = "key for "
273 }
274
275 return fmt.Sprintf(
276 "invalid %sProxyProtocolConfig.%s: %s%s",
277 key,
278 e.field,
279 e.reason,
280 cause)
281 }
282
283 var _ error = ProxyProtocolConfigValidationError{}
284
285 var _ interface {
286 Field() string
287 Reason() string
288 Key() bool
289 Cause() error
290 ErrorName() string
291 } = ProxyProtocolConfigValidationError{}