1// Code generated by protoc-gen-validate. DO NOT EDIT.
2// source: envoy/api/v2/route.proto
3
4package envoy_api_v2
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	"github.com/golang/protobuf/ptypes"
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	_ = ptypes.DynamicAny{}
34)
35
36// Validate checks the field values on RouteConfiguration with the rules
37// defined in the proto definition for this message. If any rules are
38// violated, an error is returned.
39func (m *RouteConfiguration) Validate() error {
40	if m == nil {
41		return nil
42	}
43
44	// no validation rules for Name
45
46	for idx, item := range m.GetVirtualHosts() {
47		_, _ = idx, item
48
49		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
50			if err := v.Validate(); err != nil {
51				return RouteConfigurationValidationError{
52					field:  fmt.Sprintf("VirtualHosts[%v]", idx),
53					reason: "embedded message failed validation",
54					cause:  err,
55				}
56			}
57		}
58
59	}
60
61	if v, ok := interface{}(m.GetVhds()).(interface{ Validate() error }); ok {
62		if err := v.Validate(); err != nil {
63			return RouteConfigurationValidationError{
64				field:  "Vhds",
65				reason: "embedded message failed validation",
66				cause:  err,
67			}
68		}
69	}
70
71	for idx, item := range m.GetInternalOnlyHeaders() {
72		_, _ = idx, item
73
74		if !_RouteConfiguration_InternalOnlyHeaders_Pattern.MatchString(item) {
75			return RouteConfigurationValidationError{
76				field:  fmt.Sprintf("InternalOnlyHeaders[%v]", idx),
77				reason: "value does not match regex pattern \"^[^\\x00\\n\\r]*$\"",
78			}
79		}
80
81	}
82
83	if len(m.GetResponseHeadersToAdd()) > 1000 {
84		return RouteConfigurationValidationError{
85			field:  "ResponseHeadersToAdd",
86			reason: "value must contain no more than 1000 item(s)",
87		}
88	}
89
90	for idx, item := range m.GetResponseHeadersToAdd() {
91		_, _ = idx, item
92
93		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
94			if err := v.Validate(); err != nil {
95				return RouteConfigurationValidationError{
96					field:  fmt.Sprintf("ResponseHeadersToAdd[%v]", idx),
97					reason: "embedded message failed validation",
98					cause:  err,
99				}
100			}
101		}
102
103	}
104
105	for idx, item := range m.GetResponseHeadersToRemove() {
106		_, _ = idx, item
107
108		if !_RouteConfiguration_ResponseHeadersToRemove_Pattern.MatchString(item) {
109			return RouteConfigurationValidationError{
110				field:  fmt.Sprintf("ResponseHeadersToRemove[%v]", idx),
111				reason: "value does not match regex pattern \"^[^\\x00\\n\\r]*$\"",
112			}
113		}
114
115	}
116
117	if len(m.GetRequestHeadersToAdd()) > 1000 {
118		return RouteConfigurationValidationError{
119			field:  "RequestHeadersToAdd",
120			reason: "value must contain no more than 1000 item(s)",
121		}
122	}
123
124	for idx, item := range m.GetRequestHeadersToAdd() {
125		_, _ = idx, item
126
127		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
128			if err := v.Validate(); err != nil {
129				return RouteConfigurationValidationError{
130					field:  fmt.Sprintf("RequestHeadersToAdd[%v]", idx),
131					reason: "embedded message failed validation",
132					cause:  err,
133				}
134			}
135		}
136
137	}
138
139	for idx, item := range m.GetRequestHeadersToRemove() {
140		_, _ = idx, item
141
142		if !_RouteConfiguration_RequestHeadersToRemove_Pattern.MatchString(item) {
143			return RouteConfigurationValidationError{
144				field:  fmt.Sprintf("RequestHeadersToRemove[%v]", idx),
145				reason: "value does not match regex pattern \"^[^\\x00\\n\\r]*$\"",
146			}
147		}
148
149	}
150
151	// no validation rules for MostSpecificHeaderMutationsWins
152
153	if v, ok := interface{}(m.GetValidateClusters()).(interface{ Validate() error }); ok {
154		if err := v.Validate(); err != nil {
155			return RouteConfigurationValidationError{
156				field:  "ValidateClusters",
157				reason: "embedded message failed validation",
158				cause:  err,
159			}
160		}
161	}
162
163	return nil
164}
165
166// RouteConfigurationValidationError is the validation error returned by
167// RouteConfiguration.Validate if the designated constraints aren't met.
168type RouteConfigurationValidationError struct {
169	field  string
170	reason string
171	cause  error
172	key    bool
173}
174
175// Field function returns field value.
176func (e RouteConfigurationValidationError) Field() string { return e.field }
177
178// Reason function returns reason value.
179func (e RouteConfigurationValidationError) Reason() string { return e.reason }
180
181// Cause function returns cause value.
182func (e RouteConfigurationValidationError) Cause() error { return e.cause }
183
184// Key function returns key value.
185func (e RouteConfigurationValidationError) Key() bool { return e.key }
186
187// ErrorName returns error name.
188func (e RouteConfigurationValidationError) ErrorName() string {
189	return "RouteConfigurationValidationError"
190}
191
192// Error satisfies the builtin error interface
193func (e RouteConfigurationValidationError) Error() string {
194	cause := ""
195	if e.cause != nil {
196		cause = fmt.Sprintf(" | caused by: %v", e.cause)
197	}
198
199	key := ""
200	if e.key {
201		key = "key for "
202	}
203
204	return fmt.Sprintf(
205		"invalid %sRouteConfiguration.%s: %s%s",
206		key,
207		e.field,
208		e.reason,
209		cause)
210}
211
212var _ error = RouteConfigurationValidationError{}
213
214var _ interface {
215	Field() string
216	Reason() string
217	Key() bool
218	Cause() error
219	ErrorName() string
220} = RouteConfigurationValidationError{}
221
222var _RouteConfiguration_InternalOnlyHeaders_Pattern = regexp.MustCompile("^[^\x00\n\r]*$")
223
224var _RouteConfiguration_ResponseHeadersToRemove_Pattern = regexp.MustCompile("^[^\x00\n\r]*$")
225
226var _RouteConfiguration_RequestHeadersToRemove_Pattern = regexp.MustCompile("^[^\x00\n\r]*$")
227
228// Validate checks the field values on Vhds with the rules defined in the proto
229// definition for this message. If any rules are violated, an error is returned.
230func (m *Vhds) Validate() error {
231	if m == nil {
232		return nil
233	}
234
235	if m.GetConfigSource() == nil {
236		return VhdsValidationError{
237			field:  "ConfigSource",
238			reason: "value is required",
239		}
240	}
241
242	if v, ok := interface{}(m.GetConfigSource()).(interface{ Validate() error }); ok {
243		if err := v.Validate(); err != nil {
244			return VhdsValidationError{
245				field:  "ConfigSource",
246				reason: "embedded message failed validation",
247				cause:  err,
248			}
249		}
250	}
251
252	return nil
253}
254
255// VhdsValidationError is the validation error returned by Vhds.Validate if the
256// designated constraints aren't met.
257type VhdsValidationError struct {
258	field  string
259	reason string
260	cause  error
261	key    bool
262}
263
264// Field function returns field value.
265func (e VhdsValidationError) Field() string { return e.field }
266
267// Reason function returns reason value.
268func (e VhdsValidationError) Reason() string { return e.reason }
269
270// Cause function returns cause value.
271func (e VhdsValidationError) Cause() error { return e.cause }
272
273// Key function returns key value.
274func (e VhdsValidationError) Key() bool { return e.key }
275
276// ErrorName returns error name.
277func (e VhdsValidationError) ErrorName() string { return "VhdsValidationError" }
278
279// Error satisfies the builtin error interface
280func (e VhdsValidationError) Error() string {
281	cause := ""
282	if e.cause != nil {
283		cause = fmt.Sprintf(" | caused by: %v", e.cause)
284	}
285
286	key := ""
287	if e.key {
288		key = "key for "
289	}
290
291	return fmt.Sprintf(
292		"invalid %sVhds.%s: %s%s",
293		key,
294		e.field,
295		e.reason,
296		cause)
297}
298
299var _ error = VhdsValidationError{}
300
301var _ interface {
302	Field() string
303	Reason() string
304	Key() bool
305	Cause() error
306	ErrorName() string
307} = VhdsValidationError{}
308