Debian Codegraph @

envoy/config/transport_socket/tap/v2alpha/tap.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/transport_socket/tap/v2alpha/tap.proto
4
5 package v2alpha
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 Tap with the rules defined in the proto
40 // definition for this message. If any rules are violated, the first error
41 // encountered is returned, or nil if there are no violations.
42 func (m *Tap) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on Tap with the rules defined in the
47 // proto definition for this message. If any rules are violated, the result is
48 // a list of violation errors wrapped in TapMultiError, or nil if none found.
49 func (m *Tap) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *Tap) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 if m.GetCommonConfig() == nil {
61 err := TapValidationError{
62 field: "CommonConfig",
63 reason: "value is required",
64 }
65 if !all {
66 return err
67 }
68 errors = append(errors, err)
69 }
70
71 if all {
72 switch v := interface{}(m.GetCommonConfig()).(type) {
73 case interface{ ValidateAll() error }:
74 if err := v.ValidateAll(); err != nil {
75 errors = append(errors, TapValidationError{
76 field: "CommonConfig",
77 reason: "embedded message failed validation",
78 cause: err,
79 })
80 }
81 case interface{ Validate() error }:
82 if err := v.Validate(); err != nil {
83 errors = append(errors, TapValidationError{
84 field: "CommonConfig",
85 reason: "embedded message failed validation",
86 cause: err,
87 })
88 }
89 }
90 } else if v, ok := interface{}(m.GetCommonConfig()).(interface{ Validate() error }); ok {
91 if err := v.Validate(); err != nil {
92 return TapValidationError{
93 field: "CommonConfig",
94 reason: "embedded message failed validation",
95 cause: err,
96 }
97 }
98 }
99
100 if m.GetTransportSocket() == nil {
101 err := TapValidationError{
102 field: "TransportSocket",
103 reason: "value is required",
104 }
105 if !all {
106 return err
107 }
108 errors = append(errors, err)
109 }
110
111 if all {
112 switch v := interface{}(m.GetTransportSocket()).(type) {
113 case interface{ ValidateAll() error }:
114 if err := v.ValidateAll(); err != nil {
115 errors = append(errors, TapValidationError{
116 field: "TransportSocket",
117 reason: "embedded message failed validation",
118 cause: err,
119 })
120 }
121 case interface{ Validate() error }:
122 if err := v.Validate(); err != nil {
123 errors = append(errors, TapValidationError{
124 field: "TransportSocket",
125 reason: "embedded message failed validation",
126 cause: err,
127 })
128 }
129 }
130 } else if v, ok := interface{}(m.GetTransportSocket()).(interface{ Validate() error }); ok {
131 if err := v.Validate(); err != nil {
132 return TapValidationError{
133 field: "TransportSocket",
134 reason: "embedded message failed validation",
135 cause: err,
136 }
137 }
138 }
139
140 if len(errors) > 0 {
141 return TapMultiError(errors)
142 }
143
144 return nil
145 }
146
147 // TapMultiError is an error wrapping multiple validation errors returned by
148 // Tap.ValidateAll() if the designated constraints aren't met.
149 type TapMultiError []error
150
151 // Error returns a concatenation of all the error messages it wraps.
152 func (m TapMultiError) Error() string {
153 var msgs []string
154 for _, err := range m {
155 msgs = append(msgs, err.Error())
156 }
157 return strings.Join(msgs, "; ")
158 }
159
160 // AllErrors returns a list of validation violation errors.
161 func (m TapMultiError) AllErrors() []error { return m }
162
163 // TapValidationError is the validation error returned by Tap.Validate if the
164 // designated constraints aren't met.
165 type TapValidationError struct {
166 field string
167 reason string
168 cause error
169 key bool
170 }
171
172 // Field function returns field value.
173 func (e TapValidationError) Field() string { return e.field }
174
175 // Reason function returns reason value.
176 func (e TapValidationError) Reason() string { return e.reason }
177
178 // Cause function returns cause value.
179 func (e TapValidationError) Cause() error { return e.cause }
180
181 // Key function returns key value.
182 func (e TapValidationError) Key() bool { return e.key }
183
184 // ErrorName returns error name.
185 func (e TapValidationError) ErrorName() string { return "TapValidationError" }
186
187 // Error satisfies the builtin error interface
188 func (e TapValidationError) Error() string {
189 cause := ""
190 if e.cause != nil {
191 cause = fmt.Sprintf(" | caused by: %v", e.cause)
192 }
193
194 key := ""
195 if e.key {
196 key = "key for "
197 }
198
199 return fmt.Sprintf(
200 "invalid %sTap.%s: %s%s",
201 key,
202 e.field,
203 e.reason,
204 cause)
205 }
206
207 var _ error = TapValidationError{}
208
209 var _ interface {
210 Field() string
211 Reason() string
212 Key() bool
213 Cause() error
214 ErrorName() string
215 } = TapValidationError{}