Debian Codegraph @

envoy/config/core/v3/grpc_method_list.pb.validate.go

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