Debian Codegraph @

envoy/extensions/access_loggers/file/v3/file.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/extensions/access_loggers/file/v3/file.proto
4
5 package filev3
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 FileAccessLog 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 *FileAccessLog) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on FileAccessLog 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 FileAccessLogMultiError, or
49 // nil if none found.
50 func (m *FileAccessLog) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *FileAccessLog) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 if utf8.RuneCountInString(m.GetPath()) < 1 {
62 err := FileAccessLogValidationError{
63 field: "Path",
64 reason: "value length must be at least 1 runes",
65 }
66 if !all {
67 return err
68 }
69 errors = append(errors, err)
70 }
71
72 switch v := m.AccessLogFormat.(type) {
73 case *FileAccessLog_Format:
74 if v == nil {
75 err := FileAccessLogValidationError{
76 field: "AccessLogFormat",
77 reason: "oneof value cannot be a typed-nil",
78 }
79 if !all {
80 return err
81 }
82 errors = append(errors, err)
83 }
84 // no validation rules for Format
85 case *FileAccessLog_JsonFormat:
86 if v == nil {
87 err := FileAccessLogValidationError{
88 field: "AccessLogFormat",
89 reason: "oneof value cannot be a typed-nil",
90 }
91 if !all {
92 return err
93 }
94 errors = append(errors, err)
95 }
96
97 if all {
98 switch v := interface{}(m.GetJsonFormat()).(type) {
99 case interface{ ValidateAll() error }:
100 if err := v.ValidateAll(); err != nil {
101 errors = append(errors, FileAccessLogValidationError{
102 field: "JsonFormat",
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, FileAccessLogValidationError{
110 field: "JsonFormat",
111 reason: "embedded message failed validation",
112 cause: err,
113 })
114 }
115 }
116 } else if v, ok := interface{}(m.GetJsonFormat()).(interface{ Validate() error }); ok {
117 if err := v.Validate(); err != nil {
118 return FileAccessLogValidationError{
119 field: "JsonFormat",
120 reason: "embedded message failed validation",
121 cause: err,
122 }
123 }
124 }
125
126 case *FileAccessLog_TypedJsonFormat:
127 if v == nil {
128 err := FileAccessLogValidationError{
129 field: "AccessLogFormat",
130 reason: "oneof value cannot be a typed-nil",
131 }
132 if !all {
133 return err
134 }
135 errors = append(errors, err)
136 }
137
138 if all {
139 switch v := interface{}(m.GetTypedJsonFormat()).(type) {
140 case interface{ ValidateAll() error }:
141 if err := v.ValidateAll(); err != nil {
142 errors = append(errors, FileAccessLogValidationError{
143 field: "TypedJsonFormat",
144 reason: "embedded message failed validation",
145 cause: err,
146 })
147 }
148 case interface{ Validate() error }:
149 if err := v.Validate(); err != nil {
150 errors = append(errors, FileAccessLogValidationError{
151 field: "TypedJsonFormat",
152 reason: "embedded message failed validation",
153 cause: err,
154 })
155 }
156 }
157 } else if v, ok := interface{}(m.GetTypedJsonFormat()).(interface{ Validate() error }); ok {
158 if err := v.Validate(); err != nil {
159 return FileAccessLogValidationError{
160 field: "TypedJsonFormat",
161 reason: "embedded message failed validation",
162 cause: err,
163 }
164 }
165 }
166
167 case *FileAccessLog_LogFormat:
168 if v == nil {
169 err := FileAccessLogValidationError{
170 field: "AccessLogFormat",
171 reason: "oneof value cannot be a typed-nil",
172 }
173 if !all {
174 return err
175 }
176 errors = append(errors, err)
177 }
178
179 if m.GetLogFormat() == nil {
180 err := FileAccessLogValidationError{
181 field: "LogFormat",
182 reason: "value is required",
183 }
184 if !all {
185 return err
186 }
187 errors = append(errors, err)
188 }
189
190 if all {
191 switch v := interface{}(m.GetLogFormat()).(type) {
192 case interface{ ValidateAll() error }:
193 if err := v.ValidateAll(); err != nil {
194 errors = append(errors, FileAccessLogValidationError{
195 field: "LogFormat",
196 reason: "embedded message failed validation",
197 cause: err,
198 })
199 }
200 case interface{ Validate() error }:
201 if err := v.Validate(); err != nil {
202 errors = append(errors, FileAccessLogValidationError{
203 field: "LogFormat",
204 reason: "embedded message failed validation",
205 cause: err,
206 })
207 }
208 }
209 } else if v, ok := interface{}(m.GetLogFormat()).(interface{ Validate() error }); ok {
210 if err := v.Validate(); err != nil {
211 return FileAccessLogValidationError{
212 field: "LogFormat",
213 reason: "embedded message failed validation",
214 cause: err,
215 }
216 }
217 }
218
219 default:
220 _ = v // ensures v is used
221 }
222
223 if len(errors) > 0 {
224 return FileAccessLogMultiError(errors)
225 }
226
227 return nil
228 }
229
230 // FileAccessLogMultiError is an error wrapping multiple validation errors
231 // returned by FileAccessLog.ValidateAll() if the designated constraints
232 // aren't met.
233 type FileAccessLogMultiError []error
234
235 // Error returns a concatenation of all the error messages it wraps.
236 func (m FileAccessLogMultiError) Error() string {
237 var msgs []string
238 for _, err := range m {
239 msgs = append(msgs, err.Error())
240 }
241 return strings.Join(msgs, "; ")
242 }
243
244 // AllErrors returns a list of validation violation errors.
245 func (m FileAccessLogMultiError) AllErrors() []error { return m }
246
247 // FileAccessLogValidationError is the validation error returned by
248 // FileAccessLog.Validate if the designated constraints aren't met.
249 type FileAccessLogValidationError struct {
250 field string
251 reason string
252 cause error
253 key bool
254 }
255
256 // Field function returns field value.
257 func (e FileAccessLogValidationError) Field() string { return e.field }
258
259 // Reason function returns reason value.
260 func (e FileAccessLogValidationError) Reason() string { return e.reason }
261
262 // Cause function returns cause value.
263 func (e FileAccessLogValidationError) Cause() error { return e.cause }
264
265 // Key function returns key value.
266 func (e FileAccessLogValidationError) Key() bool { return e.key }
267
268 // ErrorName returns error name.
269 func (e FileAccessLogValidationError) ErrorName() string { return "FileAccessLogValidationError" }
270
271 // Error satisfies the builtin error interface
272 func (e FileAccessLogValidationError) Error() string {
273 cause := ""
274 if e.cause != nil {
275 cause = fmt.Sprintf(" | caused by: %v", e.cause)
276 }
277
278 key := ""
279 if e.key {
280 key = "key for "
281 }
282
283 return fmt.Sprintf(
284 "invalid %sFileAccessLog.%s: %s%s",
285 key,
286 e.field,
287 e.reason,
288 cause)
289 }
290
291 var _ error = FileAccessLogValidationError{}
292
293 var _ interface {
294 Field() string
295 Reason() string
296 Key() bool
297 Cause() error
298 ErrorName() string
299 } = FileAccessLogValidationError{}