Debian Codegraph @

envoy/service/runtime/v3/rtds.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/service/runtime/v3/rtds.proto
4
5 package runtimev3
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 RtdsDummy with the rules defined in the
40 // 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 *RtdsDummy) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on RtdsDummy with the rules defined in
47 // the proto definition for this message. If any rules are violated, the
48 // result is a list of violation errors wrapped in RtdsDummyMultiError, or nil
49 // if none found.
50 func (m *RtdsDummy) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *RtdsDummy) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 if len(errors) > 0 {
62 return RtdsDummyMultiError(errors)
63 }
64
65 return nil
66 }
67
68 // RtdsDummyMultiError is an error wrapping multiple validation errors returned
69 // by RtdsDummy.ValidateAll() if the designated constraints aren't met.
70 type RtdsDummyMultiError []error
71
72 // Error returns a concatenation of all the error messages it wraps.
73 func (m RtdsDummyMultiError) Error() string {
74 var msgs []string
75 for _, err := range m {
76 msgs = append(msgs, err.Error())
77 }
78 return strings.Join(msgs, "; ")
79 }
80
81 // AllErrors returns a list of validation violation errors.
82 func (m RtdsDummyMultiError) AllErrors() []error { return m }
83
84 // RtdsDummyValidationError is the validation error returned by
85 // RtdsDummy.Validate if the designated constraints aren't met.
86 type RtdsDummyValidationError struct {
87 field string
88 reason string
89 cause error
90 key bool
91 }
92
93 // Field function returns field value.
94 func (e RtdsDummyValidationError) Field() string { return e.field }
95
96 // Reason function returns reason value.
97 func (e RtdsDummyValidationError) Reason() string { return e.reason }
98
99 // Cause function returns cause value.
100 func (e RtdsDummyValidationError) Cause() error { return e.cause }
101
102 // Key function returns key value.
103 func (e RtdsDummyValidationError) Key() bool { return e.key }
104
105 // ErrorName returns error name.
106 func (e RtdsDummyValidationError) ErrorName() string { return "RtdsDummyValidationError" }
107
108 // Error satisfies the builtin error interface
109 func (e RtdsDummyValidationError) Error() string {
110 cause := ""
111 if e.cause != nil {
112 cause = fmt.Sprintf(" | caused by: %v", e.cause)
113 }
114
115 key := ""
116 if e.key {
117 key = "key for "
118 }
119
120 return fmt.Sprintf(
121 "invalid %sRtdsDummy.%s: %s%s",
122 key,
123 e.field,
124 e.reason,
125 cause)
126 }
127
128 var _ error = RtdsDummyValidationError{}
129
130 var _ interface {
131 Field() string
132 Reason() string
133 Key() bool
134 Cause() error
135 ErrorName() string
136 } = RtdsDummyValidationError{}
137
138 // Validate checks the field values on Runtime with the rules defined in the
139 // proto definition for this message. If any rules are violated, the first
140 // error encountered is returned, or nil if there are no violations.
141 func (m *Runtime) Validate() error {
142 return m.validate(false)
143 }
144
145 // ValidateAll checks the field values on Runtime with the rules defined in the
146 // proto definition for this message. If any rules are violated, the result is
147 // a list of violation errors wrapped in RuntimeMultiError, or nil if none found.
148 func (m *Runtime) ValidateAll() error {
149 return m.validate(true)
150 }
151
152 func (m *Runtime) validate(all bool) error {
153 if m == nil {
154 return nil
155 }
156
157 var errors []error
158
159 if utf8.RuneCountInString(m.GetName()) < 1 {
160 err := RuntimeValidationError{
161 field: "Name",
162 reason: "value length must be at least 1 runes",
163 }
164 if !all {
165 return err
166 }
167 errors = append(errors, err)
168 }
169
170 if all {
171 switch v := interface{}(m.GetLayer()).(type) {
172 case interface{ ValidateAll() error }:
173 if err := v.ValidateAll(); err != nil {
174 errors = append(errors, RuntimeValidationError{
175 field: "Layer",
176 reason: "embedded message failed validation",
177 cause: err,
178 })
179 }
180 case interface{ Validate() error }:
181 if err := v.Validate(); err != nil {
182 errors = append(errors, RuntimeValidationError{
183 field: "Layer",
184 reason: "embedded message failed validation",
185 cause: err,
186 })
187 }
188 }
189 } else if v, ok := interface{}(m.GetLayer()).(interface{ Validate() error }); ok {
190 if err := v.Validate(); err != nil {
191 return RuntimeValidationError{
192 field: "Layer",
193 reason: "embedded message failed validation",
194 cause: err,
195 }
196 }
197 }
198
199 if len(errors) > 0 {
200 return RuntimeMultiError(errors)
201 }
202
203 return nil
204 }
205
206 // RuntimeMultiError is an error wrapping multiple validation errors returned
207 // by Runtime.ValidateAll() if the designated constraints aren't met.
208 type RuntimeMultiError []error
209
210 // Error returns a concatenation of all the error messages it wraps.
211 func (m RuntimeMultiError) Error() string {
212 var msgs []string
213 for _, err := range m {
214 msgs = append(msgs, err.Error())
215 }
216 return strings.Join(msgs, "; ")
217 }
218
219 // AllErrors returns a list of validation violation errors.
220 func (m RuntimeMultiError) AllErrors() []error { return m }
221
222 // RuntimeValidationError is the validation error returned by Runtime.Validate
223 // if the designated constraints aren't met.
224 type RuntimeValidationError struct {
225 field string
226 reason string
227 cause error
228 key bool
229 }
230
231 // Field function returns field value.
232 func (e RuntimeValidationError) Field() string { return e.field }
233
234 // Reason function returns reason value.
235 func (e RuntimeValidationError) Reason() string { return e.reason }
236
237 // Cause function returns cause value.
238 func (e RuntimeValidationError) Cause() error { return e.cause }
239
240 // Key function returns key value.
241 func (e RuntimeValidationError) Key() bool { return e.key }
242
243 // ErrorName returns error name.
244 func (e RuntimeValidationError) ErrorName() string { return "RuntimeValidationError" }
245
246 // Error satisfies the builtin error interface
247 func (e RuntimeValidationError) Error() string {
248 cause := ""
249 if e.cause != nil {
250 cause = fmt.Sprintf(" | caused by: %v", e.cause)
251 }
252
253 key := ""
254 if e.key {
255 key = "key for "
256 }
257
258 return fmt.Sprintf(
259 "invalid %sRuntime.%s: %s%s",
260 key,
261 e.field,
262 e.reason,
263 cause)
264 }
265
266 var _ error = RuntimeValidationError{}
267
268 var _ interface {
269 Field() string
270 Reason() string
271 Key() bool
272 Cause() error
273 ErrorName() string
274 } = RuntimeValidationError{}