| 1 |
//go:build !disable_pgv |
| 2 |
// Code generated by protoc-gen-validate. DO NOT EDIT. |
| 3 |
// source: envoy/extensions/common/ratelimit/v3/ratelimit.proto |
| 4 |
|
| 5 |
package ratelimitv3 |
| 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 |
v3 "github.com/envoyproxy/go-control-plane/envoy/type/v3" |
| 23 |
) |
| 24 |
|
| 25 |
// ensure the imports are used |
| 26 |
var ( |
| 27 |
_ = bytes.MinRead |
| 28 |
_ = errors.New("") |
| 29 |
_ = fmt.Print |
| 30 |
_ = utf8.UTFMax |
| 31 |
_ = (*regexp.Regexp)(nil) |
| 32 |
_ = (*strings.Reader)(nil) |
| 33 |
_ = net.IPv4len |
| 34 |
_ = time.Duration(0) |
| 35 |
_ = (*url.URL)(nil) |
| 36 |
_ = (*mail.Address)(nil) |
| 37 |
_ = anypb.Any{} |
| 38 |
_ = sort.Sort |
| 39 |
|
| 40 |
_ = v3.RateLimitUnit(0) |
| 41 |
) |
| 42 |
|
| 43 |
// Validate checks the field values on RateLimitDescriptor with the rules |
| 44 |
// defined in the proto definition for this message. If any rules are |
| 45 |
// violated, the first error encountered is returned, or nil if there are no violations. |
| 46 |
func (m *RateLimitDescriptor) Validate() error { |
| 47 |
return m.validate(false) |
| 48 |
} |
| 49 |
|
| 50 |
// ValidateAll checks the field values on RateLimitDescriptor with the rules |
| 51 |
// defined in the proto definition for this message. If any rules are |
| 52 |
// violated, the result is a list of violation errors wrapped in |
| 53 |
// RateLimitDescriptorMultiError, or nil if none found. |
| 54 |
func (m *RateLimitDescriptor) ValidateAll() error { |
| 55 |
return m.validate(true) |
| 56 |
} |
| 57 |
|
| 58 |
func (m *RateLimitDescriptor) validate(all bool) error { |
| 59 |
if m == nil { |
| 60 |
return nil |
| 61 |
} |
| 62 |
|
| 63 |
var errors []error |
| 64 |
|
| 65 |
if len(m.GetEntries()) < 1 { |
| 66 |
err := RateLimitDescriptorValidationError{ |
| 67 |
field: "Entries", |
| 68 |
reason: "value must contain at least 1 item(s)", |
| 69 |
} |
| 70 |
if !all { |
| 71 |
return err |
| 72 |
} |
| 73 |
errors = append(errors, err) |
| 74 |
} |
| 75 |
|
| 76 |
for idx, item := range m.GetEntries() { |
| 77 |
_, _ = idx, item |
| 78 |
|
| 79 |
if all { |
| 80 |
switch v := interface{}(item).(type) { |
| 81 |
case interface{ ValidateAll() error }: |
| 82 |
if err := v.ValidateAll(); err != nil { |
| 83 |
errors = append(errors, RateLimitDescriptorValidationError{ |
| 84 |
field: fmt.Sprintf("Entries[%v]", idx), |
| 85 |
reason: "embedded message failed validation", |
| 86 |
cause: err, |
| 87 |
}) |
| 88 |
} |
| 89 |
case interface{ Validate() error }: |
| 90 |
if err := v.Validate(); err != nil { |
| 91 |
errors = append(errors, RateLimitDescriptorValidationError{ |
| 92 |
field: fmt.Sprintf("Entries[%v]", idx), |
| 93 |
reason: "embedded message failed validation", |
| 94 |
cause: err, |
| 95 |
}) |
| 96 |
} |
| 97 |
} |
| 98 |
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
| 99 |
if err := v.Validate(); err != nil { |
| 100 |
return RateLimitDescriptorValidationError{ |
| 101 |
field: fmt.Sprintf("Entries[%v]", idx), |
| 102 |
reason: "embedded message failed validation", |
| 103 |
cause: err, |
| 104 |
} |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
} |
| 109 |
|
| 110 |
if all { |
| 111 |
switch v := interface{}(m.GetLimit()).(type) { |
| 112 |
case interface{ ValidateAll() error }: |
| 113 |
if err := v.ValidateAll(); err != nil { |
| 114 |
errors = append(errors, RateLimitDescriptorValidationError{ |
| 115 |
field: "Limit", |
| 116 |
reason: "embedded message failed validation", |
| 117 |
cause: err, |
| 118 |
}) |
| 119 |
} |
| 120 |
case interface{ Validate() error }: |
| 121 |
if err := v.Validate(); err != nil { |
| 122 |
errors = append(errors, RateLimitDescriptorValidationError{ |
| 123 |
field: "Limit", |
| 124 |
reason: "embedded message failed validation", |
| 125 |
cause: err, |
| 126 |
}) |
| 127 |
} |
| 128 |
} |
| 129 |
} else if v, ok := interface{}(m.GetLimit()).(interface{ Validate() error }); ok { |
| 130 |
if err := v.Validate(); err != nil { |
| 131 |
return RateLimitDescriptorValidationError{ |
| 132 |
field: "Limit", |
| 133 |
reason: "embedded message failed validation", |
| 134 |
cause: err, |
| 135 |
} |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
if all { |
| 140 |
switch v := interface{}(m.GetHitsAddend()).(type) { |
| 141 |
case interface{ ValidateAll() error }: |
| 142 |
if err := v.ValidateAll(); err != nil { |
| 143 |
errors = append(errors, RateLimitDescriptorValidationError{ |
| 144 |
field: "HitsAddend", |
| 145 |
reason: "embedded message failed validation", |
| 146 |
cause: err, |
| 147 |
}) |
| 148 |
} |
| 149 |
case interface{ Validate() error }: |
| 150 |
if err := v.Validate(); err != nil { |
| 151 |
errors = append(errors, RateLimitDescriptorValidationError{ |
| 152 |
field: "HitsAddend", |
| 153 |
reason: "embedded message failed validation", |
| 154 |
cause: err, |
| 155 |
}) |
| 156 |
} |
| 157 |
} |
| 158 |
} else if v, ok := interface{}(m.GetHitsAddend()).(interface{ Validate() error }); ok { |
| 159 |
if err := v.Validate(); err != nil { |
| 160 |
return RateLimitDescriptorValidationError{ |
| 161 |
field: "HitsAddend", |
| 162 |
reason: "embedded message failed validation", |
| 163 |
cause: err, |
| 164 |
} |
| 165 |
} |
| 166 |
} |
| 167 |
|
| 168 |
if len(errors) > 0 { |
| 169 |
return RateLimitDescriptorMultiError(errors) |
| 170 |
} |
| 171 |
|
| 172 |
return nil |
| 173 |
} |
| 174 |
|
| 175 |
// RateLimitDescriptorMultiError is an error wrapping multiple validation |
| 176 |
// errors returned by RateLimitDescriptor.ValidateAll() if the designated |
| 177 |
// constraints aren't met. |
| 178 |
type RateLimitDescriptorMultiError []error |
| 179 |
|
| 180 |
// Error returns a concatenation of all the error messages it wraps. |
| 181 |
func (m RateLimitDescriptorMultiError) Error() string { |
| 182 |
var msgs []string |
| 183 |
for _, err := range m { |
| 184 |
msgs = append(msgs, err.Error()) |
| 185 |
} |
| 186 |
return strings.Join(msgs, "; ") |
| 187 |
} |
| 188 |
|
| 189 |
// AllErrors returns a list of validation violation errors. |
| 190 |
func (m RateLimitDescriptorMultiError) AllErrors() []error { return m } |
| 191 |
|
| 192 |
// RateLimitDescriptorValidationError is the validation error returned by |
| 193 |
// RateLimitDescriptor.Validate if the designated constraints aren't met. |
| 194 |
type RateLimitDescriptorValidationError struct { |
| 195 |
field string |
| 196 |
reason string |
| 197 |
cause error |
| 198 |
key bool |
| 199 |
} |
| 200 |
|
| 201 |
// Field function returns field value. |
| 202 |
func (e RateLimitDescriptorValidationError) Field() string { return e.field } |
| 203 |
|
| 204 |
// Reason function returns reason value. |
| 205 |
func (e RateLimitDescriptorValidationError) Reason() string { return e.reason } |
| 206 |
|
| 207 |
// Cause function returns cause value. |
| 208 |
func (e RateLimitDescriptorValidationError) Cause() error { return e.cause } |
| 209 |
|
| 210 |
// Key function returns key value. |
| 211 |
func (e RateLimitDescriptorValidationError) Key() bool { return e.key } |
| 212 |
|
| 213 |
// ErrorName returns error name. |
| 214 |
func (e RateLimitDescriptorValidationError) ErrorName() string { |
| 215 |
return "RateLimitDescriptorValidationError" |
| 216 |
} |
| 217 |
|
| 218 |
// Error satisfies the builtin error interface |
| 219 |
func (e RateLimitDescriptorValidationError) Error() string { |
| 220 |
cause := "" |
| 221 |
if e.cause != nil { |
| 222 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 223 |
} |
| 224 |
|
| 225 |
key := "" |
| 226 |
if e.key { |
| 227 |
key = "key for " |
| 228 |
} |
| 229 |
|
| 230 |
return fmt.Sprintf( |
| 231 |
"invalid %sRateLimitDescriptor.%s: %s%s", |
| 232 |
key, |
| 233 |
e.field, |
| 234 |
e.reason, |
| 235 |
cause) |
| 236 |
} |
| 237 |
|
| 238 |
var _ error = RateLimitDescriptorValidationError{} |
| 239 |
|
| 240 |
var _ interface { |
| 241 |
Field() string |
| 242 |
Reason() string |
| 243 |
Key() bool |
| 244 |
Cause() error |
| 245 |
ErrorName() string |
| 246 |
} = RateLimitDescriptorValidationError{} |
| 247 |
|
| 248 |
// Validate checks the field values on LocalRateLimitDescriptor with the rules |
| 249 |
// defined in the proto definition for this message. If any rules are |
| 250 |
// violated, the first error encountered is returned, or nil if there are no violations. |
| 251 |
func (m *LocalRateLimitDescriptor) Validate() error { |
| 252 |
return m.validate(false) |
| 253 |
} |
| 254 |
|
| 255 |
// ValidateAll checks the field values on LocalRateLimitDescriptor with the |
| 256 |
// rules defined in the proto definition for this message. If any rules are |
| 257 |
// violated, the result is a list of violation errors wrapped in |
| 258 |
// LocalRateLimitDescriptorMultiError, or nil if none found. |
| 259 |
func (m *LocalRateLimitDescriptor) ValidateAll() error { |
| 260 |
return m.validate(true) |
| 261 |
} |
| 262 |
|
| 263 |
func (m *LocalRateLimitDescriptor) validate(all bool) error { |
| 264 |
if m == nil { |
| 265 |
return nil |
| 266 |
} |
| 267 |
|
| 268 |
var errors []error |
| 269 |
|
| 270 |
if len(m.GetEntries()) < 1 { |
| 271 |
err := LocalRateLimitDescriptorValidationError{ |
| 272 |
field: "Entries", |
| 273 |
reason: "value must contain at least 1 item(s)", |
| 274 |
} |
| 275 |
if !all { |
| 276 |
return err |
| 277 |
} |
| 278 |
errors = append(errors, err) |
| 279 |
} |
| 280 |
|
| 281 |
for idx, item := range m.GetEntries() { |
| 282 |
_, _ = idx, item |
| 283 |
|
| 284 |
if all { |
| 285 |
switch v := interface{}(item).(type) { |
| 286 |
case interface{ ValidateAll() error }: |
| 287 |
if err := v.ValidateAll(); err != nil { |
| 288 |
errors = append(errors, LocalRateLimitDescriptorValidationError{ |
| 289 |
field: fmt.Sprintf("Entries[%v]", idx), |
| 290 |
reason: "embedded message failed validation", |
| 291 |
cause: err, |
| 292 |
}) |
| 293 |
} |
| 294 |
case interface{ Validate() error }: |
| 295 |
if err := v.Validate(); err != nil { |
| 296 |
errors = append(errors, LocalRateLimitDescriptorValidationError{ |
| 297 |
field: fmt.Sprintf("Entries[%v]", idx), |
| 298 |
reason: "embedded message failed validation", |
| 299 |
cause: err, |
| 300 |
}) |
| 301 |
} |
| 302 |
} |
| 303 |
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
| 304 |
if err := v.Validate(); err != nil { |
| 305 |
return LocalRateLimitDescriptorValidationError{ |
| 306 |
field: fmt.Sprintf("Entries[%v]", idx), |
| 307 |
reason: "embedded message failed validation", |
| 308 |
cause: err, |
| 309 |
} |
| 310 |
} |
| 311 |
} |
| 312 |
|
| 313 |
} |
| 314 |
|
| 315 |
if m.GetTokenBucket() == nil { |
| 316 |
err := LocalRateLimitDescriptorValidationError{ |
| 317 |
field: "TokenBucket", |
| 318 |
reason: "value is required", |
| 319 |
} |
| 320 |
if !all { |
| 321 |
return err |
| 322 |
} |
| 323 |
errors = append(errors, err) |
| 324 |
} |
| 325 |
|
| 326 |
if all { |
| 327 |
switch v := interface{}(m.GetTokenBucket()).(type) { |
| 328 |
case interface{ ValidateAll() error }: |
| 329 |
if err := v.ValidateAll(); err != nil { |
| 330 |
errors = append(errors, LocalRateLimitDescriptorValidationError{ |
| 331 |
field: "TokenBucket", |
| 332 |
reason: "embedded message failed validation", |
| 333 |
cause: err, |
| 334 |
}) |
| 335 |
} |
| 336 |
case interface{ Validate() error }: |
| 337 |
if err := v.Validate(); err != nil { |
| 338 |
errors = append(errors, LocalRateLimitDescriptorValidationError{ |
| 339 |
field: "TokenBucket", |
| 340 |
reason: "embedded message failed validation", |
| 341 |
cause: err, |
| 342 |
}) |
| 343 |
} |
| 344 |
} |
| 345 |
} else if v, ok := interface{}(m.GetTokenBucket()).(interface{ Validate() error }); ok { |
| 346 |
if err := v.Validate(); err != nil { |
| 347 |
return LocalRateLimitDescriptorValidationError{ |
| 348 |
field: "TokenBucket", |
| 349 |
reason: "embedded message failed validation", |
| 350 |
cause: err, |
| 351 |
} |
| 352 |
} |
| 353 |
} |
| 354 |
|
| 355 |
if len(errors) > 0 { |
| 356 |
return LocalRateLimitDescriptorMultiError(errors) |
| 357 |
} |
| 358 |
|
| 359 |
return nil |
| 360 |
} |
| 361 |
|
| 362 |
// LocalRateLimitDescriptorMultiError is an error wrapping multiple validation |
| 363 |
// errors returned by LocalRateLimitDescriptor.ValidateAll() if the designated |
| 364 |
// constraints aren't met. |
| 365 |
type LocalRateLimitDescriptorMultiError []error |
| 366 |
|
| 367 |
// Error returns a concatenation of all the error messages it wraps. |
| 368 |
func (m LocalRateLimitDescriptorMultiError) Error() string { |
| 369 |
var msgs []string |
| 370 |
for _, err := range m { |
| 371 |
msgs = append(msgs, err.Error()) |
| 372 |
} |
| 373 |
return strings.Join(msgs, "; ") |
| 374 |
} |
| 375 |
|
| 376 |
// AllErrors returns a list of validation violation errors. |
| 377 |
func (m LocalRateLimitDescriptorMultiError) AllErrors() []error { return m } |
| 378 |
|
| 379 |
// LocalRateLimitDescriptorValidationError is the validation error returned by |
| 380 |
// LocalRateLimitDescriptor.Validate if the designated constraints aren't met. |
| 381 |
type LocalRateLimitDescriptorValidationError struct { |
| 382 |
field string |
| 383 |
reason string |
| 384 |
cause error |
| 385 |
key bool |
| 386 |
} |
| 387 |
|
| 388 |
// Field function returns field value. |
| 389 |
func (e LocalRateLimitDescriptorValidationError) Field() string { return e.field } |
| 390 |
|
| 391 |
// Reason function returns reason value. |
| 392 |
func (e LocalRateLimitDescriptorValidationError) Reason() string { return e.reason } |
| 393 |
|
| 394 |
// Cause function returns cause value. |
| 395 |
func (e LocalRateLimitDescriptorValidationError) Cause() error { return e.cause } |
| 396 |
|
| 397 |
// Key function returns key value. |
| 398 |
func (e LocalRateLimitDescriptorValidationError) Key() bool { return e.key } |
| 399 |
|
| 400 |
// ErrorName returns error name. |
| 401 |
func (e LocalRateLimitDescriptorValidationError) ErrorName() string { |
| 402 |
return "LocalRateLimitDescriptorValidationError" |
| 403 |
} |
| 404 |
|
| 405 |
// Error satisfies the builtin error interface |
| 406 |
func (e LocalRateLimitDescriptorValidationError) Error() string { |
| 407 |
cause := "" |
| 408 |
if e.cause != nil { |
| 409 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 410 |
} |
| 411 |
|
| 412 |
key := "" |
| 413 |
if e.key { |
| 414 |
key = "key for " |
| 415 |
} |
| 416 |
|
| 417 |
return fmt.Sprintf( |
| 418 |
"invalid %sLocalRateLimitDescriptor.%s: %s%s", |
| 419 |
key, |
| 420 |
e.field, |
| 421 |
e.reason, |
| 422 |
cause) |
| 423 |
} |
| 424 |
|
| 425 |
var _ error = LocalRateLimitDescriptorValidationError{} |
| 426 |
|
| 427 |
var _ interface { |
| 428 |
Field() string |
| 429 |
Reason() string |
| 430 |
Key() bool |
| 431 |
Cause() error |
| 432 |
ErrorName() string |
| 433 |
} = LocalRateLimitDescriptorValidationError{} |
| 434 |
|
| 435 |
// Validate checks the field values on LocalClusterRateLimit with the rules |
| 436 |
// defined in the proto definition for this message. If any rules are |
| 437 |
// violated, the first error encountered is returned, or nil if there are no violations. |
| 438 |
func (m *LocalClusterRateLimit) Validate() error { |
| 439 |
return m.validate(false) |
| 440 |
} |
| 441 |
|
| 442 |
// ValidateAll checks the field values on LocalClusterRateLimit with the rules |
| 443 |
// defined in the proto definition for this message. If any rules are |
| 444 |
// violated, the result is a list of violation errors wrapped in |
| 445 |
// LocalClusterRateLimitMultiError, or nil if none found. |
| 446 |
func (m *LocalClusterRateLimit) ValidateAll() error { |
| 447 |
return m.validate(true) |
| 448 |
} |
| 449 |
|
| 450 |
func (m *LocalClusterRateLimit) validate(all bool) error { |
| 451 |
if m == nil { |
| 452 |
return nil |
| 453 |
} |
| 454 |
|
| 455 |
var errors []error |
| 456 |
|
| 457 |
if len(errors) > 0 { |
| 458 |
return LocalClusterRateLimitMultiError(errors) |
| 459 |
} |
| 460 |
|
| 461 |
return nil |
| 462 |
} |
| 463 |
|
| 464 |
// LocalClusterRateLimitMultiError is an error wrapping multiple validation |
| 465 |
// errors returned by LocalClusterRateLimit.ValidateAll() if the designated |
| 466 |
// constraints aren't met. |
| 467 |
type LocalClusterRateLimitMultiError []error |
| 468 |
|
| 469 |
// Error returns a concatenation of all the error messages it wraps. |
| 470 |
func (m LocalClusterRateLimitMultiError) Error() string { |
| 471 |
var msgs []string |
| 472 |
for _, err := range m { |
| 473 |
msgs = append(msgs, err.Error()) |
| 474 |
} |
| 475 |
return strings.Join(msgs, "; ") |
| 476 |
} |
| 477 |
|
| 478 |
// AllErrors returns a list of validation violation errors. |
| 479 |
func (m LocalClusterRateLimitMultiError) AllErrors() []error { return m } |
| 480 |
|
| 481 |
// LocalClusterRateLimitValidationError is the validation error returned by |
| 482 |
// LocalClusterRateLimit.Validate if the designated constraints aren't met. |
| 483 |
type LocalClusterRateLimitValidationError struct { |
| 484 |
field string |
| 485 |
reason string |
| 486 |
cause error |
| 487 |
key bool |
| 488 |
} |
| 489 |
|
| 490 |
// Field function returns field value. |
| 491 |
func (e LocalClusterRateLimitValidationError) Field() string { return e.field } |
| 492 |
|
| 493 |
// Reason function returns reason value. |
| 494 |
func (e LocalClusterRateLimitValidationError) Reason() string { return e.reason } |
| 495 |
|
| 496 |
// Cause function returns cause value. |
| 497 |
func (e LocalClusterRateLimitValidationError) Cause() error { return e.cause } |
| 498 |
|
| 499 |
// Key function returns key value. |
| 500 |
func (e LocalClusterRateLimitValidationError) Key() bool { return e.key } |
| 501 |
|
| 502 |
// ErrorName returns error name. |
| 503 |
func (e LocalClusterRateLimitValidationError) ErrorName() string { |
| 504 |
return "LocalClusterRateLimitValidationError" |
| 505 |
} |
| 506 |
|
| 507 |
// Error satisfies the builtin error interface |
| 508 |
func (e LocalClusterRateLimitValidationError) Error() string { |
| 509 |
cause := "" |
| 510 |
if e.cause != nil { |
| 511 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 512 |
} |
| 513 |
|
| 514 |
key := "" |
| 515 |
if e.key { |
| 516 |
key = "key for " |
| 517 |
} |
| 518 |
|
| 519 |
return fmt.Sprintf( |
| 520 |
"invalid %sLocalClusterRateLimit.%s: %s%s", |
| 521 |
key, |
| 522 |
e.field, |
| 523 |
e.reason, |
| 524 |
cause) |
| 525 |
} |
| 526 |
|
| 527 |
var _ error = LocalClusterRateLimitValidationError{} |
| 528 |
|
| 529 |
var _ interface { |
| 530 |
Field() string |
| 531 |
Reason() string |
| 532 |
Key() bool |
| 533 |
Cause() error |
| 534 |
ErrorName() string |
| 535 |
} = LocalClusterRateLimitValidationError{} |
| 536 |
|
| 537 |
// Validate checks the field values on RateLimitDescriptor_Entry with the rules |
| 538 |
// defined in the proto definition for this message. If any rules are |
| 539 |
// violated, the first error encountered is returned, or nil if there are no violations. |
| 540 |
func (m *RateLimitDescriptor_Entry) Validate() error { |
| 541 |
return m.validate(false) |
| 542 |
} |
| 543 |
|
| 544 |
// ValidateAll checks the field values on RateLimitDescriptor_Entry with the |
| 545 |
// rules defined in the proto definition for this message. If any rules are |
| 546 |
// violated, the result is a list of violation errors wrapped in |
| 547 |
// RateLimitDescriptor_EntryMultiError, or nil if none found. |
| 548 |
func (m *RateLimitDescriptor_Entry) ValidateAll() error { |
| 549 |
return m.validate(true) |
| 550 |
} |
| 551 |
|
| 552 |
func (m *RateLimitDescriptor_Entry) validate(all bool) error { |
| 553 |
if m == nil { |
| 554 |
return nil |
| 555 |
} |
| 556 |
|
| 557 |
var errors []error |
| 558 |
|
| 559 |
if utf8.RuneCountInString(m.GetKey()) < 1 { |
| 560 |
err := RateLimitDescriptor_EntryValidationError{ |
| 561 |
field: "Key", |
| 562 |
reason: "value length must be at least 1 runes", |
| 563 |
} |
| 564 |
if !all { |
| 565 |
return err |
| 566 |
} |
| 567 |
errors = append(errors, err) |
| 568 |
} |
| 569 |
|
| 570 |
if utf8.RuneCountInString(m.GetValue()) < 1 { |
| 571 |
err := RateLimitDescriptor_EntryValidationError{ |
| 572 |
field: "Value", |
| 573 |
reason: "value length must be at least 1 runes", |
| 574 |
} |
| 575 |
if !all { |
| 576 |
return err |
| 577 |
} |
| 578 |
errors = append(errors, err) |
| 579 |
} |
| 580 |
|
| 581 |
if len(errors) > 0 { |
| 582 |
return RateLimitDescriptor_EntryMultiError(errors) |
| 583 |
} |
| 584 |
|
| 585 |
return nil |
| 586 |
} |
| 587 |
|
| 588 |
// RateLimitDescriptor_EntryMultiError is an error wrapping multiple validation |
| 589 |
// errors returned by RateLimitDescriptor_Entry.ValidateAll() if the |
| 590 |
// designated constraints aren't met. |
| 591 |
type RateLimitDescriptor_EntryMultiError []error |
| 592 |
|
| 593 |
// Error returns a concatenation of all the error messages it wraps. |
| 594 |
func (m RateLimitDescriptor_EntryMultiError) Error() string { |
| 595 |
var msgs []string |
| 596 |
for _, err := range m { |
| 597 |
msgs = append(msgs, err.Error()) |
| 598 |
} |
| 599 |
return strings.Join(msgs, "; ") |
| 600 |
} |
| 601 |
|
| 602 |
// AllErrors returns a list of validation violation errors. |
| 603 |
func (m RateLimitDescriptor_EntryMultiError) AllErrors() []error { return m } |
| 604 |
|
| 605 |
// RateLimitDescriptor_EntryValidationError is the validation error returned by |
| 606 |
// RateLimitDescriptor_Entry.Validate if the designated constraints aren't met. |
| 607 |
type RateLimitDescriptor_EntryValidationError struct { |
| 608 |
field string |
| 609 |
reason string |
| 610 |
cause error |
| 611 |
key bool |
| 612 |
} |
| 613 |
|
| 614 |
// Field function returns field value. |
| 615 |
func (e RateLimitDescriptor_EntryValidationError) Field() string { return e.field } |
| 616 |
|
| 617 |
// Reason function returns reason value. |
| 618 |
func (e RateLimitDescriptor_EntryValidationError) Reason() string { return e.reason } |
| 619 |
|
| 620 |
// Cause function returns cause value. |
| 621 |
func (e RateLimitDescriptor_EntryValidationError) Cause() error { return e.cause } |
| 622 |
|
| 623 |
// Key function returns key value. |
| 624 |
func (e RateLimitDescriptor_EntryValidationError) Key() bool { return e.key } |
| 625 |
|
| 626 |
// ErrorName returns error name. |
| 627 |
func (e RateLimitDescriptor_EntryValidationError) ErrorName() string { |
| 628 |
return "RateLimitDescriptor_EntryValidationError" |
| 629 |
} |
| 630 |
|
| 631 |
// Error satisfies the builtin error interface |
| 632 |
func (e RateLimitDescriptor_EntryValidationError) Error() string { |
| 633 |
cause := "" |
| 634 |
if e.cause != nil { |
| 635 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 636 |
} |
| 637 |
|
| 638 |
key := "" |
| 639 |
if e.key { |
| 640 |
key = "key for " |
| 641 |
} |
| 642 |
|
| 643 |
return fmt.Sprintf( |
| 644 |
"invalid %sRateLimitDescriptor_Entry.%s: %s%s", |
| 645 |
key, |
| 646 |
e.field, |
| 647 |
e.reason, |
| 648 |
cause) |
| 649 |
} |
| 650 |
|
| 651 |
var _ error = RateLimitDescriptor_EntryValidationError{} |
| 652 |
|
| 653 |
var _ interface { |
| 654 |
Field() string |
| 655 |
Reason() string |
| 656 |
Key() bool |
| 657 |
Cause() error |
| 658 |
ErrorName() string |
| 659 |
} = RateLimitDescriptor_EntryValidationError{} |
| 660 |
|
| 661 |
// Validate checks the field values on RateLimitDescriptor_RateLimitOverride |
| 662 |
// with the rules defined in the proto definition for this message. If any |
| 663 |
// rules are violated, the first error encountered is returned, or nil if |
| 664 |
// there are no violations. |
| 665 |
func (m *RateLimitDescriptor_RateLimitOverride) Validate() error { |
| 666 |
return m.validate(false) |
| 667 |
} |
| 668 |
|
| 669 |
// ValidateAll checks the field values on RateLimitDescriptor_RateLimitOverride |
| 670 |
// with the rules defined in the proto definition for this message. If any |
| 671 |
// rules are violated, the result is a list of violation errors wrapped in |
| 672 |
// RateLimitDescriptor_RateLimitOverrideMultiError, or nil if none found. |
| 673 |
func (m *RateLimitDescriptor_RateLimitOverride) ValidateAll() error { |
| 674 |
return m.validate(true) |
| 675 |
} |
| 676 |
|
| 677 |
func (m *RateLimitDescriptor_RateLimitOverride) validate(all bool) error { |
| 678 |
if m == nil { |
| 679 |
return nil |
| 680 |
} |
| 681 |
|
| 682 |
var errors []error |
| 683 |
|
| 684 |
// no validation rules for RequestsPerUnit |
| 685 |
|
| 686 |
if _, ok := v3.RateLimitUnit_name[int32(m.GetUnit())]; !ok { |
| 687 |
err := RateLimitDescriptor_RateLimitOverrideValidationError{ |
| 688 |
field: "Unit", |
| 689 |
reason: "value must be one of the defined enum values", |
| 690 |
} |
| 691 |
if !all { |
| 692 |
return err |
| 693 |
} |
| 694 |
errors = append(errors, err) |
| 695 |
} |
| 696 |
|
| 697 |
if len(errors) > 0 { |
| 698 |
return RateLimitDescriptor_RateLimitOverrideMultiError(errors) |
| 699 |
} |
| 700 |
|
| 701 |
return nil |
| 702 |
} |
| 703 |
|
| 704 |
// RateLimitDescriptor_RateLimitOverrideMultiError is an error wrapping |
| 705 |
// multiple validation errors returned by |
| 706 |
// RateLimitDescriptor_RateLimitOverride.ValidateAll() if the designated |
| 707 |
// constraints aren't met. |
| 708 |
type RateLimitDescriptor_RateLimitOverrideMultiError []error |
| 709 |
|
| 710 |
// Error returns a concatenation of all the error messages it wraps. |
| 711 |
func (m RateLimitDescriptor_RateLimitOverrideMultiError) Error() string { |
| 712 |
var msgs []string |
| 713 |
for _, err := range m { |
| 714 |
msgs = append(msgs, err.Error()) |
| 715 |
} |
| 716 |
return strings.Join(msgs, "; ") |
| 717 |
} |
| 718 |
|
| 719 |
// AllErrors returns a list of validation violation errors. |
| 720 |
func (m RateLimitDescriptor_RateLimitOverrideMultiError) AllErrors() []error { return m } |
| 721 |
|
| 722 |
// RateLimitDescriptor_RateLimitOverrideValidationError is the validation error |
| 723 |
// returned by RateLimitDescriptor_RateLimitOverride.Validate if the |
| 724 |
// designated constraints aren't met. |
| 725 |
type RateLimitDescriptor_RateLimitOverrideValidationError struct { |
| 726 |
field string |
| 727 |
reason string |
| 728 |
cause error |
| 729 |
key bool |
| 730 |
} |
| 731 |
|
| 732 |
// Field function returns field value. |
| 733 |
func (e RateLimitDescriptor_RateLimitOverrideValidationError) Field() string { return e.field } |
| 734 |
|
| 735 |
// Reason function returns reason value. |
| 736 |
func (e RateLimitDescriptor_RateLimitOverrideValidationError) Reason() string { return e.reason } |
| 737 |
|
| 738 |
// Cause function returns cause value. |
| 739 |
func (e RateLimitDescriptor_RateLimitOverrideValidationError) Cause() error { return e.cause } |
| 740 |
|
| 741 |
// Key function returns key value. |
| 742 |
func (e RateLimitDescriptor_RateLimitOverrideValidationError) Key() bool { return e.key } |
| 743 |
|
| 744 |
// ErrorName returns error name. |
| 745 |
func (e RateLimitDescriptor_RateLimitOverrideValidationError) ErrorName() string { |
| 746 |
return "RateLimitDescriptor_RateLimitOverrideValidationError" |
| 747 |
} |
| 748 |
|
| 749 |
// Error satisfies the builtin error interface |
| 750 |
func (e RateLimitDescriptor_RateLimitOverrideValidationError) Error() string { |
| 751 |
cause := "" |
| 752 |
if e.cause != nil { |
| 753 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 754 |
} |
| 755 |
|
| 756 |
key := "" |
| 757 |
if e.key { |
| 758 |
key = "key for " |
| 759 |
} |
| 760 |
|
| 761 |
return fmt.Sprintf( |
| 762 |
"invalid %sRateLimitDescriptor_RateLimitOverride.%s: %s%s", |
| 763 |
key, |
| 764 |
e.field, |
| 765 |
e.reason, |
| 766 |
cause) |
| 767 |
} |
| 768 |
|
| 769 |
var _ error = RateLimitDescriptor_RateLimitOverrideValidationError{} |
| 770 |
|
| 771 |
var _ interface { |
| 772 |
Field() string |
| 773 |
Reason() string |
| 774 |
Key() bool |
| 775 |
Cause() error |
| 776 |
ErrorName() string |
| 777 |
} = RateLimitDescriptor_RateLimitOverrideValidationError{} |