1// Code generated by protoc-gen-validate. DO NOT EDIT.
2// source: envoy/type/matcher/v3/value.proto
3
4package envoy_type_matcher_v3
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// define the regex for a UUID once up-front
37var _value_uuidPattern = regexp.MustCompile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")
38
39// Validate checks the field values on ValueMatcher with the rules defined in
40// the proto definition for this message. If any rules are violated, an error
41// is returned.
42func (m *ValueMatcher) Validate() error {
43	if m == nil {
44		return nil
45	}
46
47	switch m.MatchPattern.(type) {
48
49	case *ValueMatcher_NullMatch_:
50
51		if v, ok := interface{}(m.GetNullMatch()).(interface{ Validate() error }); ok {
52			if err := v.Validate(); err != nil {
53				return ValueMatcherValidationError{
54					field:  "NullMatch",
55					reason: "embedded message failed validation",
56					cause:  err,
57				}
58			}
59		}
60
61	case *ValueMatcher_DoubleMatch:
62
63		if v, ok := interface{}(m.GetDoubleMatch()).(interface{ Validate() error }); ok {
64			if err := v.Validate(); err != nil {
65				return ValueMatcherValidationError{
66					field:  "DoubleMatch",
67					reason: "embedded message failed validation",
68					cause:  err,
69				}
70			}
71		}
72
73	case *ValueMatcher_StringMatch:
74
75		if v, ok := interface{}(m.GetStringMatch()).(interface{ Validate() error }); ok {
76			if err := v.Validate(); err != nil {
77				return ValueMatcherValidationError{
78					field:  "StringMatch",
79					reason: "embedded message failed validation",
80					cause:  err,
81				}
82			}
83		}
84
85	case *ValueMatcher_BoolMatch:
86		// no validation rules for BoolMatch
87
88	case *ValueMatcher_PresentMatch:
89		// no validation rules for PresentMatch
90
91	case *ValueMatcher_ListMatch:
92
93		if v, ok := interface{}(m.GetListMatch()).(interface{ Validate() error }); ok {
94			if err := v.Validate(); err != nil {
95				return ValueMatcherValidationError{
96					field:  "ListMatch",
97					reason: "embedded message failed validation",
98					cause:  err,
99				}
100			}
101		}
102
103	default:
104		return ValueMatcherValidationError{
105			field:  "MatchPattern",
106			reason: "value is required",
107		}
108
109	}
110
111	return nil
112}
113
114// ValueMatcherValidationError is the validation error returned by
115// ValueMatcher.Validate if the designated constraints aren't met.
116type ValueMatcherValidationError struct {
117	field  string
118	reason string
119	cause  error
120	key    bool
121}
122
123// Field function returns field value.
124func (e ValueMatcherValidationError) Field() string { return e.field }
125
126// Reason function returns reason value.
127func (e ValueMatcherValidationError) Reason() string { return e.reason }
128
129// Cause function returns cause value.
130func (e ValueMatcherValidationError) Cause() error { return e.cause }
131
132// Key function returns key value.
133func (e ValueMatcherValidationError) Key() bool { return e.key }
134
135// ErrorName returns error name.
136func (e ValueMatcherValidationError) ErrorName() string { return "ValueMatcherValidationError" }
137
138// Error satisfies the builtin error interface
139func (e ValueMatcherValidationError) Error() string {
140	cause := ""
141	if e.cause != nil {
142		cause = fmt.Sprintf(" | caused by: %v", e.cause)
143	}
144
145	key := ""
146	if e.key {
147		key = "key for "
148	}
149
150	return fmt.Sprintf(
151		"invalid %sValueMatcher.%s: %s%s",
152		key,
153		e.field,
154		e.reason,
155		cause)
156}
157
158var _ error = ValueMatcherValidationError{}
159
160var _ interface {
161	Field() string
162	Reason() string
163	Key() bool
164	Cause() error
165	ErrorName() string
166} = ValueMatcherValidationError{}
167
168// Validate checks the field values on ListMatcher with the rules defined in
169// the proto definition for this message. If any rules are violated, an error
170// is returned.
171func (m *ListMatcher) Validate() error {
172	if m == nil {
173		return nil
174	}
175
176	switch m.MatchPattern.(type) {
177
178	case *ListMatcher_OneOf:
179
180		if v, ok := interface{}(m.GetOneOf()).(interface{ Validate() error }); ok {
181			if err := v.Validate(); err != nil {
182				return ListMatcherValidationError{
183					field:  "OneOf",
184					reason: "embedded message failed validation",
185					cause:  err,
186				}
187			}
188		}
189
190	default:
191		return ListMatcherValidationError{
192			field:  "MatchPattern",
193			reason: "value is required",
194		}
195
196	}
197
198	return nil
199}
200
201// ListMatcherValidationError is the validation error returned by
202// ListMatcher.Validate if the designated constraints aren't met.
203type ListMatcherValidationError struct {
204	field  string
205	reason string
206	cause  error
207	key    bool
208}
209
210// Field function returns field value.
211func (e ListMatcherValidationError) Field() string { return e.field }
212
213// Reason function returns reason value.
214func (e ListMatcherValidationError) Reason() string { return e.reason }
215
216// Cause function returns cause value.
217func (e ListMatcherValidationError) Cause() error { return e.cause }
218
219// Key function returns key value.
220func (e ListMatcherValidationError) Key() bool { return e.key }
221
222// ErrorName returns error name.
223func (e ListMatcherValidationError) ErrorName() string { return "ListMatcherValidationError" }
224
225// Error satisfies the builtin error interface
226func (e ListMatcherValidationError) Error() string {
227	cause := ""
228	if e.cause != nil {
229		cause = fmt.Sprintf(" | caused by: %v", e.cause)
230	}
231
232	key := ""
233	if e.key {
234		key = "key for "
235	}
236
237	return fmt.Sprintf(
238		"invalid %sListMatcher.%s: %s%s",
239		key,
240		e.field,
241		e.reason,
242		cause)
243}
244
245var _ error = ListMatcherValidationError{}
246
247var _ interface {
248	Field() string
249	Reason() string
250	Key() bool
251	Cause() error
252	ErrorName() string
253} = ListMatcherValidationError{}
254
255// Validate checks the field values on ValueMatcher_NullMatch with the rules
256// defined in the proto definition for this message. If any rules are
257// violated, an error is returned.
258func (m *ValueMatcher_NullMatch) Validate() error {
259	if m == nil {
260		return nil
261	}
262
263	return nil
264}
265
266// ValueMatcher_NullMatchValidationError is the validation error returned by
267// ValueMatcher_NullMatch.Validate if the designated constraints aren't met.
268type ValueMatcher_NullMatchValidationError struct {
269	field  string
270	reason string
271	cause  error
272	key    bool
273}
274
275// Field function returns field value.
276func (e ValueMatcher_NullMatchValidationError) Field() string { return e.field }
277
278// Reason function returns reason value.
279func (e ValueMatcher_NullMatchValidationError) Reason() string { return e.reason }
280
281// Cause function returns cause value.
282func (e ValueMatcher_NullMatchValidationError) Cause() error { return e.cause }
283
284// Key function returns key value.
285func (e ValueMatcher_NullMatchValidationError) Key() bool { return e.key }
286
287// ErrorName returns error name.
288func (e ValueMatcher_NullMatchValidationError) ErrorName() string {
289	return "ValueMatcher_NullMatchValidationError"
290}
291
292// Error satisfies the builtin error interface
293func (e ValueMatcher_NullMatchValidationError) Error() string {
294	cause := ""
295	if e.cause != nil {
296		cause = fmt.Sprintf(" | caused by: %v", e.cause)
297	}
298
299	key := ""
300	if e.key {
301		key = "key for "
302	}
303
304	return fmt.Sprintf(
305		"invalid %sValueMatcher_NullMatch.%s: %s%s",
306		key,
307		e.field,
308		e.reason,
309		cause)
310}
311
312var _ error = ValueMatcher_NullMatchValidationError{}
313
314var _ interface {
315	Field() string
316	Reason() string
317	Key() bool
318	Cause() error
319	ErrorName() string
320} = ValueMatcher_NullMatchValidationError{}
321