Debian Codegraph @

envoy/extensions/transport_sockets/tcp_stats/v3/tcp_stats.pb.validate.go

raw symbols SCIP
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/extensions/transport_sockets/tcp_stats/v3/tcp_stats.proto
4
5 package tcp_statsv3
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 Config 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 *Config) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on Config 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 ConfigMultiError, or nil if none found.
49 func (m *Config) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *Config) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 if m.GetTransportSocket() == nil {
61 err := ConfigValidationError{
62 field: "TransportSocket",
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.GetTransportSocket()).(type) {
73 case interface{ ValidateAll() error }:
74 if err := v.ValidateAll(); err != nil {
75 errors = append(errors, ConfigValidationError{
76 field: "TransportSocket",
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, ConfigValidationError{
84 field: "TransportSocket",
85 reason: "embedded message failed validation",
86 cause: err,
87 })
88 }
89 }
90 } else if v, ok := interface{}(m.GetTransportSocket()).(interface{ Validate() error }); ok {
91 if err := v.Validate(); err != nil {
92 return ConfigValidationError{
93 field: "TransportSocket",
94 reason: "embedded message failed validation",
95 cause: err,
96 }
97 }
98 }
99
100 if d := m.GetUpdatePeriod(); d != nil {
101 dur, err := d.AsDuration(), d.CheckValid()
102 if err != nil {
103 err = ConfigValidationError{
104 field: "UpdatePeriod",
105 reason: "value is not a valid duration",
106 cause: err,
107 }
108 if !all {
109 return err
110 }
111 errors = append(errors, err)
112 } else {
113
114 gte := time.Duration(0*time.Second + 1000000*time.Nanosecond)
115
116 if dur < gte {
117 err := ConfigValidationError{
118 field: "UpdatePeriod",
119 reason: "value must be greater than or equal to 1ms",
120 }
121 if !all {
122 return err
123 }
124 errors = append(errors, err)
125 }
126
127 }
128 }
129
130 if len(errors) > 0 {
131 return ConfigMultiError(errors)
132 }
133
134 return nil
135 }
136
137 // ConfigMultiError is an error wrapping multiple validation errors returned by
138 // Config.ValidateAll() if the designated constraints aren't met.
139 type ConfigMultiError []error
140
141 // Error returns a concatenation of all the error messages it wraps.
142 func (m ConfigMultiError) Error() string {
143 var msgs []string
144 for _, err := range m {
145 msgs = append(msgs, err.Error())
146 }
147 return strings.Join(msgs, "; ")
148 }
149
150 // AllErrors returns a list of validation violation errors.
151 func (m ConfigMultiError) AllErrors() []error { return m }
152
153 // ConfigValidationError is the validation error returned by Config.Validate if
154 // the designated constraints aren't met.
155 type ConfigValidationError struct {
156 field string
157 reason string
158 cause error
159 key bool
160 }
161
162 // Field function returns field value.
163 func (e ConfigValidationError) Field() string { return e.field }
164
165 // Reason function returns reason value.
166 func (e ConfigValidationError) Reason() string { return e.reason }
167
168 // Cause function returns cause value.
169 func (e ConfigValidationError) Cause() error { return e.cause }
170
171 // Key function returns key value.
172 func (e ConfigValidationError) Key() bool { return e.key }
173
174 // ErrorName returns error name.
175 func (e ConfigValidationError) ErrorName() string { return "ConfigValidationError" }
176
177 // Error satisfies the builtin error interface
178 func (e ConfigValidationError) Error() string {
179 cause := ""
180 if e.cause != nil {
181 cause = fmt.Sprintf(" | caused by: %v", e.cause)
182 }
183
184 key := ""
185 if e.key {
186 key = "key for "
187 }
188
189 return fmt.Sprintf(
190 "invalid %sConfig.%s: %s%s",
191 key,
192 e.field,
193 e.reason,
194 cause)
195 }
196
197 var _ error = ConfigValidationError{}
198
199 var _ interface {
200 Field() string
201 Reason() string
202 Key() bool
203 Cause() error
204 ErrorName() string
205 } = ConfigValidationError{}