Debian Codegraph @

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

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