/pkg/api/envoy/extensions/common/ratelimit/v3/ratelimit.pb.validate.go

https://github.com/datawire/ambassador · Go · 298 lines · 204 code · 55 blank · 39 comment · 26 complexity · 382a5c6549e9eb8aa1222feb567c2e3b MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/extensions/common/ratelimit/v3/ratelimit.proto
  3. package envoy_extensions_common_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. v3 "github.com/datawire/ambassador/pkg/api/envoy/type/v3"
  17. )
  18. // ensure the imports are used
  19. var (
  20. _ = bytes.MinRead
  21. _ = errors.New("")
  22. _ = fmt.Print
  23. _ = utf8.UTFMax
  24. _ = (*regexp.Regexp)(nil)
  25. _ = (*strings.Reader)(nil)
  26. _ = net.IPv4len
  27. _ = time.Duration(0)
  28. _ = (*url.URL)(nil)
  29. _ = (*mail.Address)(nil)
  30. _ = ptypes.DynamicAny{}
  31. _ = v3.RateLimitUnit(0)
  32. )
  33. // define the regex for a UUID once up-front
  34. var _ratelimit_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}$")
  35. // Validate checks the field values on RateLimitDescriptor with the rules
  36. // defined in the proto definition for this message. If any rules are
  37. // violated, an error is returned.
  38. func (m *RateLimitDescriptor) Validate() error {
  39. if m == nil {
  40. return nil
  41. }
  42. if len(m.GetEntries()) < 1 {
  43. return RateLimitDescriptorValidationError{
  44. field: "Entries",
  45. reason: "value must contain at least 1 item(s)",
  46. }
  47. }
  48. for idx, item := range m.GetEntries() {
  49. _, _ = idx, item
  50. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  51. if err := v.Validate(); err != nil {
  52. return RateLimitDescriptorValidationError{
  53. field: fmt.Sprintf("Entries[%v]", idx),
  54. reason: "embedded message failed validation",
  55. cause: err,
  56. }
  57. }
  58. }
  59. }
  60. if v, ok := interface{}(m.GetLimit()).(interface{ Validate() error }); ok {
  61. if err := v.Validate(); err != nil {
  62. return RateLimitDescriptorValidationError{
  63. field: "Limit",
  64. reason: "embedded message failed validation",
  65. cause: err,
  66. }
  67. }
  68. }
  69. return nil
  70. }
  71. // RateLimitDescriptorValidationError is the validation error returned by
  72. // RateLimitDescriptor.Validate if the designated constraints aren't met.
  73. type RateLimitDescriptorValidationError struct {
  74. field string
  75. reason string
  76. cause error
  77. key bool
  78. }
  79. // Field function returns field value.
  80. func (e RateLimitDescriptorValidationError) Field() string { return e.field }
  81. // Reason function returns reason value.
  82. func (e RateLimitDescriptorValidationError) Reason() string { return e.reason }
  83. // Cause function returns cause value.
  84. func (e RateLimitDescriptorValidationError) Cause() error { return e.cause }
  85. // Key function returns key value.
  86. func (e RateLimitDescriptorValidationError) Key() bool { return e.key }
  87. // ErrorName returns error name.
  88. func (e RateLimitDescriptorValidationError) ErrorName() string {
  89. return "RateLimitDescriptorValidationError"
  90. }
  91. // Error satisfies the builtin error interface
  92. func (e RateLimitDescriptorValidationError) Error() string {
  93. cause := ""
  94. if e.cause != nil {
  95. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  96. }
  97. key := ""
  98. if e.key {
  99. key = "key for "
  100. }
  101. return fmt.Sprintf(
  102. "invalid %sRateLimitDescriptor.%s: %s%s",
  103. key,
  104. e.field,
  105. e.reason,
  106. cause)
  107. }
  108. var _ error = RateLimitDescriptorValidationError{}
  109. var _ interface {
  110. Field() string
  111. Reason() string
  112. Key() bool
  113. Cause() error
  114. ErrorName() string
  115. } = RateLimitDescriptorValidationError{}
  116. // Validate checks the field values on RateLimitDescriptor_Entry with the rules
  117. // defined in the proto definition for this message. If any rules are
  118. // violated, an error is returned.
  119. func (m *RateLimitDescriptor_Entry) Validate() error {
  120. if m == nil {
  121. return nil
  122. }
  123. if len(m.GetKey()) < 1 {
  124. return RateLimitDescriptor_EntryValidationError{
  125. field: "Key",
  126. reason: "value length must be at least 1 bytes",
  127. }
  128. }
  129. if len(m.GetValue()) < 1 {
  130. return RateLimitDescriptor_EntryValidationError{
  131. field: "Value",
  132. reason: "value length must be at least 1 bytes",
  133. }
  134. }
  135. return nil
  136. }
  137. // RateLimitDescriptor_EntryValidationError is the validation error returned by
  138. // RateLimitDescriptor_Entry.Validate if the designated constraints aren't met.
  139. type RateLimitDescriptor_EntryValidationError struct {
  140. field string
  141. reason string
  142. cause error
  143. key bool
  144. }
  145. // Field function returns field value.
  146. func (e RateLimitDescriptor_EntryValidationError) Field() string { return e.field }
  147. // Reason function returns reason value.
  148. func (e RateLimitDescriptor_EntryValidationError) Reason() string { return e.reason }
  149. // Cause function returns cause value.
  150. func (e RateLimitDescriptor_EntryValidationError) Cause() error { return e.cause }
  151. // Key function returns key value.
  152. func (e RateLimitDescriptor_EntryValidationError) Key() bool { return e.key }
  153. // ErrorName returns error name.
  154. func (e RateLimitDescriptor_EntryValidationError) ErrorName() string {
  155. return "RateLimitDescriptor_EntryValidationError"
  156. }
  157. // Error satisfies the builtin error interface
  158. func (e RateLimitDescriptor_EntryValidationError) Error() string {
  159. cause := ""
  160. if e.cause != nil {
  161. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  162. }
  163. key := ""
  164. if e.key {
  165. key = "key for "
  166. }
  167. return fmt.Sprintf(
  168. "invalid %sRateLimitDescriptor_Entry.%s: %s%s",
  169. key,
  170. e.field,
  171. e.reason,
  172. cause)
  173. }
  174. var _ error = RateLimitDescriptor_EntryValidationError{}
  175. var _ interface {
  176. Field() string
  177. Reason() string
  178. Key() bool
  179. Cause() error
  180. ErrorName() string
  181. } = RateLimitDescriptor_EntryValidationError{}
  182. // Validate checks the field values on RateLimitDescriptor_RateLimitOverride
  183. // with the rules defined in the proto definition for this message. If any
  184. // rules are violated, an error is returned.
  185. func (m *RateLimitDescriptor_RateLimitOverride) Validate() error {
  186. if m == nil {
  187. return nil
  188. }
  189. // no validation rules for RequestsPerUnit
  190. if _, ok := v3.RateLimitUnit_name[int32(m.GetUnit())]; !ok {
  191. return RateLimitDescriptor_RateLimitOverrideValidationError{
  192. field: "Unit",
  193. reason: "value must be one of the defined enum values",
  194. }
  195. }
  196. return nil
  197. }
  198. // RateLimitDescriptor_RateLimitOverrideValidationError is the validation error
  199. // returned by RateLimitDescriptor_RateLimitOverride.Validate if the
  200. // designated constraints aren't met.
  201. type RateLimitDescriptor_RateLimitOverrideValidationError struct {
  202. field string
  203. reason string
  204. cause error
  205. key bool
  206. }
  207. // Field function returns field value.
  208. func (e RateLimitDescriptor_RateLimitOverrideValidationError) Field() string { return e.field }
  209. // Reason function returns reason value.
  210. func (e RateLimitDescriptor_RateLimitOverrideValidationError) Reason() string { return e.reason }
  211. // Cause function returns cause value.
  212. func (e RateLimitDescriptor_RateLimitOverrideValidationError) Cause() error { return e.cause }
  213. // Key function returns key value.
  214. func (e RateLimitDescriptor_RateLimitOverrideValidationError) Key() bool { return e.key }
  215. // ErrorName returns error name.
  216. func (e RateLimitDescriptor_RateLimitOverrideValidationError) ErrorName() string {
  217. return "RateLimitDescriptor_RateLimitOverrideValidationError"
  218. }
  219. // Error satisfies the builtin error interface
  220. func (e RateLimitDescriptor_RateLimitOverrideValidationError) Error() string {
  221. cause := ""
  222. if e.cause != nil {
  223. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  224. }
  225. key := ""
  226. if e.key {
  227. key = "key for "
  228. }
  229. return fmt.Sprintf(
  230. "invalid %sRateLimitDescriptor_RateLimitOverride.%s: %s%s",
  231. key,
  232. e.field,
  233. e.reason,
  234. cause)
  235. }
  236. var _ error = RateLimitDescriptor_RateLimitOverrideValidationError{}
  237. var _ interface {
  238. Field() string
  239. Reason() string
  240. Key() bool
  241. Cause() error
  242. ErrorName() string
  243. } = RateLimitDescriptor_RateLimitOverrideValidationError{}