Debian Codegraph @

go/xds/type/matcher/v3/regex.pb.validate.go

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