Debian Codegraph @

envoy/config/accesslog/v2/file.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/accesslog/v2/file.proto
4
5 package accesslogv2
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 len(m.GetPath()) < 1 {
62 err := FileAccessLogValidationError{
63 field: "Path",
64 reason: "value length must be at least 1 bytes",
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 default:
168 _ = v // ensures v is used
169 }
170
171 if len(errors) > 0 {
172 return FileAccessLogMultiError(errors)
173 }
174
175 return nil
176 }
177
178 // FileAccessLogMultiError is an error wrapping multiple validation errors
179 // returned by FileAccessLog.ValidateAll() if the designated constraints
180 // aren't met.
181 type FileAccessLogMultiError []error
182
183 // Error returns a concatenation of all the error messages it wraps.
184 func (m FileAccessLogMultiError) Error() string {
185 var msgs []string
186 for _, err := range m {
187 msgs = append(msgs, err.Error())
188 }
189 return strings.Join(msgs, "; ")
190 }
191
192 // AllErrors returns a list of validation violation errors.
193 func (m FileAccessLogMultiError) AllErrors() []error { return m }
194
195 // FileAccessLogValidationError is the validation error returned by
196 // FileAccessLog.Validate if the designated constraints aren't met.
197 type FileAccessLogValidationError struct {
198 field string
199 reason string
200 cause error
201 key bool
202 }
203
204 // Field function returns field value.
205 func (e FileAccessLogValidationError) Field() string { return e.field }
206
207 // Reason function returns reason value.
208 func (e FileAccessLogValidationError) Reason() string { return e.reason }
209
210 // Cause function returns cause value.
211 func (e FileAccessLogValidationError) Cause() error { return e.cause }
212
213 // Key function returns key value.
214 func (e FileAccessLogValidationError) Key() bool { return e.key }
215
216 // ErrorName returns error name.
217 func (e FileAccessLogValidationError) ErrorName() string { return "FileAccessLogValidationError" }
218
219 // Error satisfies the builtin error interface
220 func (e FileAccessLogValidationError) Error() string {
221 cause := ""
222 if e.cause != nil {
223 cause = fmt.Sprintf(" | caused by: %v", e.cause)
224 }
225
226 key := ""
227 if e.key {
228 key = "key for "
229 }
230
231 return fmt.Sprintf(
232 "invalid %sFileAccessLog.%s: %s%s",
233 key,
234 e.field,
235 e.reason,
236 cause)
237 }
238
239 var _ error = FileAccessLogValidationError{}
240
241 var _ interface {
242 Field() string
243 Reason() string
244 Key() bool
245 Cause() error
246 ErrorName() string
247 } = FileAccessLogValidationError{}