/pkg/api/envoy/config/filter/thrift/rate_limit/v2alpha1/rate_limit.pb.validate.go

https://github.com/datawire/ambassador · Go · 144 lines · 105 code · 24 blank · 15 comment · 15 complexity · ecf28f4eff4be45d267c41e6576b6c11 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/config/filter/thrift/rate_limit/v2alpha1/rate_limit.proto
  3. package envoy_config_filter_thrift_rate_limit_v2alpha1
  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 v, ok := interface{}(m.GetTimeout()).(interface{ Validate() error }); ok {
  52. if err := v.Validate(); err != nil {
  53. return RateLimitValidationError{
  54. field: "Timeout",
  55. reason: "embedded message failed validation",
  56. cause: err,
  57. }
  58. }
  59. }
  60. // no validation rules for FailureModeDeny
  61. if m.GetRateLimitService() == nil {
  62. return RateLimitValidationError{
  63. field: "RateLimitService",
  64. reason: "value is required",
  65. }
  66. }
  67. if v, ok := interface{}(m.GetRateLimitService()).(interface{ Validate() error }); ok {
  68. if err := v.Validate(); err != nil {
  69. return RateLimitValidationError{
  70. field: "RateLimitService",
  71. reason: "embedded message failed validation",
  72. cause: err,
  73. }
  74. }
  75. }
  76. return nil
  77. }
  78. // RateLimitValidationError is the validation error returned by
  79. // RateLimit.Validate if the designated constraints aren't met.
  80. type RateLimitValidationError struct {
  81. field string
  82. reason string
  83. cause error
  84. key bool
  85. }
  86. // Field function returns field value.
  87. func (e RateLimitValidationError) Field() string { return e.field }
  88. // Reason function returns reason value.
  89. func (e RateLimitValidationError) Reason() string { return e.reason }
  90. // Cause function returns cause value.
  91. func (e RateLimitValidationError) Cause() error { return e.cause }
  92. // Key function returns key value.
  93. func (e RateLimitValidationError) Key() bool { return e.key }
  94. // ErrorName returns error name.
  95. func (e RateLimitValidationError) ErrorName() string { return "RateLimitValidationError" }
  96. // Error satisfies the builtin error interface
  97. func (e RateLimitValidationError) Error() string {
  98. cause := ""
  99. if e.cause != nil {
  100. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  101. }
  102. key := ""
  103. if e.key {
  104. key = "key for "
  105. }
  106. return fmt.Sprintf(
  107. "invalid %sRateLimit.%s: %s%s",
  108. key,
  109. e.field,
  110. e.reason,
  111. cause)
  112. }
  113. var _ error = RateLimitValidationError{}
  114. var _ interface {
  115. Field() string
  116. Reason() string
  117. Key() bool
  118. Cause() error
  119. ErrorName() string
  120. } = RateLimitValidationError{}