/pkg/api/envoy/extensions/filters/http/ratelimit/v3/rate_limit.pb.validate.go

https://github.com/datawire/ambassador · Go · 160 lines · 117 code · 27 blank · 16 comment · 16 complexity · 0fe7114129074bf2849463a0709fb26a MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/extensions/filters/http/ratelimit/v3/rate_limit.proto
  3. package envoy_extensions_filters_http_ratelimit_v3
  4. import (
  5. "bytes"
  6. "errors"
  7. "fmt"
  8. "net"
  9. "net/mail"
  10. "net/url"
  11. "regexp"
  12. "strings"
  13. "time"
  14. "unicode/utf8"
  15. "github.com/golang/protobuf/ptypes"
  16. )
  17. // ensure the imports are used
  18. var (
  19. _ = bytes.MinRead
  20. _ = errors.New("")
  21. _ = fmt.Print
  22. _ = utf8.UTFMax
  23. _ = (*regexp.Regexp)(nil)
  24. _ = (*strings.Reader)(nil)
  25. _ = net.IPv4len
  26. _ = time.Duration(0)
  27. _ = (*url.URL)(nil)
  28. _ = (*mail.Address)(nil)
  29. _ = ptypes.DynamicAny{}
  30. )
  31. // define the regex for a UUID once up-front
  32. var _rate_limit_uuidPattern = regexp.MustCompile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")
  33. // Validate checks the field values on RateLimit with the rules defined in the
  34. // proto definition for this message. If any rules are violated, an error is returned.
  35. func (m *RateLimit) Validate() error {
  36. if m == nil {
  37. return nil
  38. }
  39. if len(m.GetDomain()) < 1 {
  40. return RateLimitValidationError{
  41. field: "Domain",
  42. reason: "value length must be at least 1 bytes",
  43. }
  44. }
  45. if m.GetStage() > 10 {
  46. return RateLimitValidationError{
  47. field: "Stage",
  48. reason: "value must be less than or equal to 10",
  49. }
  50. }
  51. if _, ok := _RateLimit_RequestType_InLookup[m.GetRequestType()]; !ok {
  52. return RateLimitValidationError{
  53. field: "RequestType",
  54. reason: "value must be in list [internal external both ]",
  55. }
  56. }
  57. if v, ok := interface{}(m.GetTimeout()).(interface{ Validate() error }); ok {
  58. if err := v.Validate(); err != nil {
  59. return RateLimitValidationError{
  60. field: "Timeout",
  61. reason: "embedded message failed validation",
  62. cause: err,
  63. }
  64. }
  65. }
  66. // no validation rules for FailureModeDeny
  67. // no validation rules for RateLimitedAsResourceExhausted
  68. if m.GetRateLimitService() == nil {
  69. return RateLimitValidationError{
  70. field: "RateLimitService",
  71. reason: "value is required",
  72. }
  73. }
  74. if v, ok := interface{}(m.GetRateLimitService()).(interface{ Validate() error }); ok {
  75. if err := v.Validate(); err != nil {
  76. return RateLimitValidationError{
  77. field: "RateLimitService",
  78. reason: "embedded message failed validation",
  79. cause: err,
  80. }
  81. }
  82. }
  83. return nil
  84. }
  85. // RateLimitValidationError is the validation error returned by
  86. // RateLimit.Validate if the designated constraints aren't met.
  87. type RateLimitValidationError struct {
  88. field string
  89. reason string
  90. cause error
  91. key bool
  92. }
  93. // Field function returns field value.
  94. func (e RateLimitValidationError) Field() string { return e.field }
  95. // Reason function returns reason value.
  96. func (e RateLimitValidationError) Reason() string { return e.reason }
  97. // Cause function returns cause value.
  98. func (e RateLimitValidationError) Cause() error { return e.cause }
  99. // Key function returns key value.
  100. func (e RateLimitValidationError) Key() bool { return e.key }
  101. // ErrorName returns error name.
  102. func (e RateLimitValidationError) ErrorName() string { return "RateLimitValidationError" }
  103. // Error satisfies the builtin error interface
  104. func (e RateLimitValidationError) Error() string {
  105. cause := ""
  106. if e.cause != nil {
  107. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  108. }
  109. key := ""
  110. if e.key {
  111. key = "key for "
  112. }
  113. return fmt.Sprintf(
  114. "invalid %sRateLimit.%s: %s%s",
  115. key,
  116. e.field,
  117. e.reason,
  118. cause)
  119. }
  120. var _ error = RateLimitValidationError{}
  121. var _ interface {
  122. Field() string
  123. Reason() string
  124. Key() bool
  125. Cause() error
  126. ErrorName() string
  127. } = RateLimitValidationError{}
  128. var _RateLimit_RequestType_InLookup = map[string]struct{}{
  129. "internal": {},
  130. "external": {},
  131. "both": {},
  132. "": {},
  133. }