1// Code generated by protoc-gen-validate. DO NOT EDIT.
2// source: envoy/config/filter/network/thrift_proxy/v2alpha1/thrift_proxy.proto
3
4package envoy_config_filter_network_thrift_proxy_v2alpha1
5
6import (
7	"bytes"
8	"errors"
9	"fmt"
10	"net"
11	"net/mail"
12	"net/url"
13	"regexp"
14	"strings"
15	"time"
16	"unicode/utf8"
17
18	"google.golang.org/protobuf/types/known/anypb"
19)
20
21// ensure the imports are used
22var (
23	_ = bytes.MinRead
24	_ = errors.New("")
25	_ = fmt.Print
26	_ = utf8.UTFMax
27	_ = (*regexp.Regexp)(nil)
28	_ = (*strings.Reader)(nil)
29	_ = net.IPv4len
30	_ = time.Duration(0)
31	_ = (*url.URL)(nil)
32	_ = (*mail.Address)(nil)
33	_ = anypb.Any{}
34)
35
36// Validate checks the field values on ThriftProxy with the rules defined in
37// the proto definition for this message. If any rules are violated, an error
38// is returned.
39func (m *ThriftProxy) Validate() error {
40	if m == nil {
41		return nil
42	}
43
44	if _, ok := TransportType_name[int32(m.GetTransport())]; !ok {
45		return ThriftProxyValidationError{
46			field:  "Transport",
47			reason: "value must be one of the defined enum values",
48		}
49	}
50
51	if _, ok := ProtocolType_name[int32(m.GetProtocol())]; !ok {
52		return ThriftProxyValidationError{
53			field:  "Protocol",
54			reason: "value must be one of the defined enum values",
55		}
56	}
57
58	if len(m.GetStatPrefix()) < 1 {
59		return ThriftProxyValidationError{
60			field:  "StatPrefix",
61			reason: "value length must be at least 1 bytes",
62		}
63	}
64
65	if v, ok := interface{}(m.GetRouteConfig()).(interface{ Validate() error }); ok {
66		if err := v.Validate(); err != nil {
67			return ThriftProxyValidationError{
68				field:  "RouteConfig",
69				reason: "embedded message failed validation",
70				cause:  err,
71			}
72		}
73	}
74
75	for idx, item := range m.GetThriftFilters() {
76		_, _ = idx, item
77
78		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
79			if err := v.Validate(); err != nil {
80				return ThriftProxyValidationError{
81					field:  fmt.Sprintf("ThriftFilters[%v]", idx),
82					reason: "embedded message failed validation",
83					cause:  err,
84				}
85			}
86		}
87
88	}
89
90	return nil
91}
92
93// ThriftProxyValidationError is the validation error returned by
94// ThriftProxy.Validate if the designated constraints aren't met.
95type ThriftProxyValidationError struct {
96	field  string
97	reason string
98	cause  error
99	key    bool
100}
101
102// Field function returns field value.
103func (e ThriftProxyValidationError) Field() string { return e.field }
104
105// Reason function returns reason value.
106func (e ThriftProxyValidationError) Reason() string { return e.reason }
107
108// Cause function returns cause value.
109func (e ThriftProxyValidationError) Cause() error { return e.cause }
110
111// Key function returns key value.
112func (e ThriftProxyValidationError) Key() bool { return e.key }
113
114// ErrorName returns error name.
115func (e ThriftProxyValidationError) ErrorName() string { return "ThriftProxyValidationError" }
116
117// Error satisfies the builtin error interface
118func (e ThriftProxyValidationError) Error() string {
119	cause := ""
120	if e.cause != nil {
121		cause = fmt.Sprintf(" | caused by: %v", e.cause)
122	}
123
124	key := ""
125	if e.key {
126		key = "key for "
127	}
128
129	return fmt.Sprintf(
130		"invalid %sThriftProxy.%s: %s%s",
131		key,
132		e.field,
133		e.reason,
134		cause)
135}
136
137var _ error = ThriftProxyValidationError{}
138
139var _ interface {
140	Field() string
141	Reason() string
142	Key() bool
143	Cause() error
144	ErrorName() string
145} = ThriftProxyValidationError{}
146
147// Validate checks the field values on ThriftFilter with the rules defined in
148// the proto definition for this message. If any rules are violated, an error
149// is returned.
150func (m *ThriftFilter) Validate() error {
151	if m == nil {
152		return nil
153	}
154
155	if len(m.GetName()) < 1 {
156		return ThriftFilterValidationError{
157			field:  "Name",
158			reason: "value length must be at least 1 bytes",
159		}
160	}
161
162	switch m.ConfigType.(type) {
163
164	case *ThriftFilter_Config:
165
166		if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok {
167			if err := v.Validate(); err != nil {
168				return ThriftFilterValidationError{
169					field:  "Config",
170					reason: "embedded message failed validation",
171					cause:  err,
172				}
173			}
174		}
175
176	case *ThriftFilter_TypedConfig:
177
178		if v, ok := interface{}(m.GetTypedConfig()).(interface{ Validate() error }); ok {
179			if err := v.Validate(); err != nil {
180				return ThriftFilterValidationError{
181					field:  "TypedConfig",
182					reason: "embedded message failed validation",
183					cause:  err,
184				}
185			}
186		}
187
188	}
189
190	return nil
191}
192
193// ThriftFilterValidationError is the validation error returned by
194// ThriftFilter.Validate if the designated constraints aren't met.
195type ThriftFilterValidationError struct {
196	field  string
197	reason string
198	cause  error
199	key    bool
200}
201
202// Field function returns field value.
203func (e ThriftFilterValidationError) Field() string { return e.field }
204
205// Reason function returns reason value.
206func (e ThriftFilterValidationError) Reason() string { return e.reason }
207
208// Cause function returns cause value.
209func (e ThriftFilterValidationError) Cause() error { return e.cause }
210
211// Key function returns key value.
212func (e ThriftFilterValidationError) Key() bool { return e.key }
213
214// ErrorName returns error name.
215func (e ThriftFilterValidationError) ErrorName() string { return "ThriftFilterValidationError" }
216
217// Error satisfies the builtin error interface
218func (e ThriftFilterValidationError) Error() string {
219	cause := ""
220	if e.cause != nil {
221		cause = fmt.Sprintf(" | caused by: %v", e.cause)
222	}
223
224	key := ""
225	if e.key {
226		key = "key for "
227	}
228
229	return fmt.Sprintf(
230		"invalid %sThriftFilter.%s: %s%s",
231		key,
232		e.field,
233		e.reason,
234		cause)
235}
236
237var _ error = ThriftFilterValidationError{}
238
239var _ interface {
240	Field() string
241	Reason() string
242	Key() bool
243	Cause() error
244	ErrorName() string
245} = ThriftFilterValidationError{}
246
247// Validate checks the field values on ThriftProtocolOptions with the rules
248// defined in the proto definition for this message. If any rules are
249// violated, an error is returned.
250func (m *ThriftProtocolOptions) Validate() error {
251	if m == nil {
252		return nil
253	}
254
255	if _, ok := TransportType_name[int32(m.GetTransport())]; !ok {
256		return ThriftProtocolOptionsValidationError{
257			field:  "Transport",
258			reason: "value must be one of the defined enum values",
259		}
260	}
261
262	if _, ok := ProtocolType_name[int32(m.GetProtocol())]; !ok {
263		return ThriftProtocolOptionsValidationError{
264			field:  "Protocol",
265			reason: "value must be one of the defined enum values",
266		}
267	}
268
269	return nil
270}
271
272// ThriftProtocolOptionsValidationError is the validation error returned by
273// ThriftProtocolOptions.Validate if the designated constraints aren't met.
274type ThriftProtocolOptionsValidationError struct {
275	field  string
276	reason string
277	cause  error
278	key    bool
279}
280
281// Field function returns field value.
282func (e ThriftProtocolOptionsValidationError) Field() string { return e.field }
283
284// Reason function returns reason value.
285func (e ThriftProtocolOptionsValidationError) Reason() string { return e.reason }
286
287// Cause function returns cause value.
288func (e ThriftProtocolOptionsValidationError) Cause() error { return e.cause }
289
290// Key function returns key value.
291func (e ThriftProtocolOptionsValidationError) Key() bool { return e.key }
292
293// ErrorName returns error name.
294func (e ThriftProtocolOptionsValidationError) ErrorName() string {
295	return "ThriftProtocolOptionsValidationError"
296}
297
298// Error satisfies the builtin error interface
299func (e ThriftProtocolOptionsValidationError) Error() string {
300	cause := ""
301	if e.cause != nil {
302		cause = fmt.Sprintf(" | caused by: %v", e.cause)
303	}
304
305	key := ""
306	if e.key {
307		key = "key for "
308	}
309
310	return fmt.Sprintf(
311		"invalid %sThriftProtocolOptions.%s: %s%s",
312		key,
313		e.field,
314		e.reason,
315		cause)
316}
317
318var _ error = ThriftProtocolOptionsValidationError{}
319
320var _ interface {
321	Field() string
322	Reason() string
323	Key() bool
324	Cause() error
325	ErrorName() string
326} = ThriftProtocolOptionsValidationError{}
327