Debian Codegraph @

envoy/config/core/v3/backoff.pb.validate.go

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