/pkg/api/envoy/config/filter/http/cache/v2alpha/cache.pb.validate.go

https://github.com/datawire/ambassador · Go · 242 lines · 165 code · 47 blank · 30 comment · 29 complexity · 68460fffceb80c44959fc3818c0f8ad5 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/config/filter/http/cache/v2alpha/cache.proto
  3. package envoy_config_filter_http_cache_v2alpha
  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 _cache_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 CacheConfig with the rules defined in
  34. // the proto definition for this message. If any rules are violated, an error
  35. // is returned.
  36. func (m *CacheConfig) Validate() error {
  37. if m == nil {
  38. return nil
  39. }
  40. if m.GetTypedConfig() == nil {
  41. return CacheConfigValidationError{
  42. field: "TypedConfig",
  43. reason: "value is required",
  44. }
  45. }
  46. if a := m.GetTypedConfig(); a != nil {
  47. }
  48. for idx, item := range m.GetAllowedVaryHeaders() {
  49. _, _ = idx, item
  50. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  51. if err := v.Validate(); err != nil {
  52. return CacheConfigValidationError{
  53. field: fmt.Sprintf("AllowedVaryHeaders[%v]", idx),
  54. reason: "embedded message failed validation",
  55. cause: err,
  56. }
  57. }
  58. }
  59. }
  60. if v, ok := interface{}(m.GetKeyCreatorParams()).(interface{ Validate() error }); ok {
  61. if err := v.Validate(); err != nil {
  62. return CacheConfigValidationError{
  63. field: "KeyCreatorParams",
  64. reason: "embedded message failed validation",
  65. cause: err,
  66. }
  67. }
  68. }
  69. // no validation rules for MaxBodyBytes
  70. return nil
  71. }
  72. // CacheConfigValidationError is the validation error returned by
  73. // CacheConfig.Validate if the designated constraints aren't met.
  74. type CacheConfigValidationError struct {
  75. field string
  76. reason string
  77. cause error
  78. key bool
  79. }
  80. // Field function returns field value.
  81. func (e CacheConfigValidationError) Field() string { return e.field }
  82. // Reason function returns reason value.
  83. func (e CacheConfigValidationError) Reason() string { return e.reason }
  84. // Cause function returns cause value.
  85. func (e CacheConfigValidationError) Cause() error { return e.cause }
  86. // Key function returns key value.
  87. func (e CacheConfigValidationError) Key() bool { return e.key }
  88. // ErrorName returns error name.
  89. func (e CacheConfigValidationError) ErrorName() string { return "CacheConfigValidationError" }
  90. // Error satisfies the builtin error interface
  91. func (e CacheConfigValidationError) Error() string {
  92. cause := ""
  93. if e.cause != nil {
  94. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  95. }
  96. key := ""
  97. if e.key {
  98. key = "key for "
  99. }
  100. return fmt.Sprintf(
  101. "invalid %sCacheConfig.%s: %s%s",
  102. key,
  103. e.field,
  104. e.reason,
  105. cause)
  106. }
  107. var _ error = CacheConfigValidationError{}
  108. var _ interface {
  109. Field() string
  110. Reason() string
  111. Key() bool
  112. Cause() error
  113. ErrorName() string
  114. } = CacheConfigValidationError{}
  115. // Validate checks the field values on CacheConfig_KeyCreatorParams with the
  116. // rules defined in the proto definition for this message. If any rules are
  117. // violated, an error is returned.
  118. func (m *CacheConfig_KeyCreatorParams) Validate() error {
  119. if m == nil {
  120. return nil
  121. }
  122. // no validation rules for ExcludeScheme
  123. // no validation rules for ExcludeHost
  124. for idx, item := range m.GetQueryParametersIncluded() {
  125. _, _ = idx, item
  126. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  127. if err := v.Validate(); err != nil {
  128. return CacheConfig_KeyCreatorParamsValidationError{
  129. field: fmt.Sprintf("QueryParametersIncluded[%v]", idx),
  130. reason: "embedded message failed validation",
  131. cause: err,
  132. }
  133. }
  134. }
  135. }
  136. for idx, item := range m.GetQueryParametersExcluded() {
  137. _, _ = idx, item
  138. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  139. if err := v.Validate(); err != nil {
  140. return CacheConfig_KeyCreatorParamsValidationError{
  141. field: fmt.Sprintf("QueryParametersExcluded[%v]", idx),
  142. reason: "embedded message failed validation",
  143. cause: err,
  144. }
  145. }
  146. }
  147. }
  148. return nil
  149. }
  150. // CacheConfig_KeyCreatorParamsValidationError is the validation error returned
  151. // by CacheConfig_KeyCreatorParams.Validate if the designated constraints
  152. // aren't met.
  153. type CacheConfig_KeyCreatorParamsValidationError struct {
  154. field string
  155. reason string
  156. cause error
  157. key bool
  158. }
  159. // Field function returns field value.
  160. func (e CacheConfig_KeyCreatorParamsValidationError) Field() string { return e.field }
  161. // Reason function returns reason value.
  162. func (e CacheConfig_KeyCreatorParamsValidationError) Reason() string { return e.reason }
  163. // Cause function returns cause value.
  164. func (e CacheConfig_KeyCreatorParamsValidationError) Cause() error { return e.cause }
  165. // Key function returns key value.
  166. func (e CacheConfig_KeyCreatorParamsValidationError) Key() bool { return e.key }
  167. // ErrorName returns error name.
  168. func (e CacheConfig_KeyCreatorParamsValidationError) ErrorName() string {
  169. return "CacheConfig_KeyCreatorParamsValidationError"
  170. }
  171. // Error satisfies the builtin error interface
  172. func (e CacheConfig_KeyCreatorParamsValidationError) Error() string {
  173. cause := ""
  174. if e.cause != nil {
  175. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  176. }
  177. key := ""
  178. if e.key {
  179. key = "key for "
  180. }
  181. return fmt.Sprintf(
  182. "invalid %sCacheConfig_KeyCreatorParams.%s: %s%s",
  183. key,
  184. e.field,
  185. e.reason,
  186. cause)
  187. }
  188. var _ error = CacheConfig_KeyCreatorParamsValidationError{}
  189. var _ interface {
  190. Field() string
  191. Reason() string
  192. Key() bool
  193. Cause() error
  194. ErrorName() string
  195. } = CacheConfig_KeyCreatorParamsValidationError{}