/pkg/api/envoy/config/route/v3/scoped_route.pb.validate.go

https://github.com/datawire/ambassador · Go · 306 lines · 210 code · 56 blank · 40 comment · 28 complexity · f3f5a10dceaba13eb2c45af870c27e5c MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/config/route/v3/scoped_route.proto
  3. package envoy_config_route_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 _scoped_route_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 ScopedRouteConfiguration with the rules
  34. // defined in the proto definition for this message. If any rules are
  35. // violated, an error is returned.
  36. func (m *ScopedRouteConfiguration) Validate() error {
  37. if m == nil {
  38. return nil
  39. }
  40. if len(m.GetName()) < 1 {
  41. return ScopedRouteConfigurationValidationError{
  42. field: "Name",
  43. reason: "value length must be at least 1 bytes",
  44. }
  45. }
  46. if len(m.GetRouteConfigurationName()) < 1 {
  47. return ScopedRouteConfigurationValidationError{
  48. field: "RouteConfigurationName",
  49. reason: "value length must be at least 1 bytes",
  50. }
  51. }
  52. if m.GetKey() == nil {
  53. return ScopedRouteConfigurationValidationError{
  54. field: "Key",
  55. reason: "value is required",
  56. }
  57. }
  58. if v, ok := interface{}(m.GetKey()).(interface{ Validate() error }); ok {
  59. if err := v.Validate(); err != nil {
  60. return ScopedRouteConfigurationValidationError{
  61. field: "Key",
  62. reason: "embedded message failed validation",
  63. cause: err,
  64. }
  65. }
  66. }
  67. return nil
  68. }
  69. // ScopedRouteConfigurationValidationError is the validation error returned by
  70. // ScopedRouteConfiguration.Validate if the designated constraints aren't met.
  71. type ScopedRouteConfigurationValidationError struct {
  72. field string
  73. reason string
  74. cause error
  75. key bool
  76. }
  77. // Field function returns field value.
  78. func (e ScopedRouteConfigurationValidationError) Field() string { return e.field }
  79. // Reason function returns reason value.
  80. func (e ScopedRouteConfigurationValidationError) Reason() string { return e.reason }
  81. // Cause function returns cause value.
  82. func (e ScopedRouteConfigurationValidationError) Cause() error { return e.cause }
  83. // Key function returns key value.
  84. func (e ScopedRouteConfigurationValidationError) Key() bool { return e.key }
  85. // ErrorName returns error name.
  86. func (e ScopedRouteConfigurationValidationError) ErrorName() string {
  87. return "ScopedRouteConfigurationValidationError"
  88. }
  89. // Error satisfies the builtin error interface
  90. func (e ScopedRouteConfigurationValidationError) Error() string {
  91. cause := ""
  92. if e.cause != nil {
  93. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  94. }
  95. key := ""
  96. if e.key {
  97. key = "key for "
  98. }
  99. return fmt.Sprintf(
  100. "invalid %sScopedRouteConfiguration.%s: %s%s",
  101. key,
  102. e.field,
  103. e.reason,
  104. cause)
  105. }
  106. var _ error = ScopedRouteConfigurationValidationError{}
  107. var _ interface {
  108. Field() string
  109. Reason() string
  110. Key() bool
  111. Cause() error
  112. ErrorName() string
  113. } = ScopedRouteConfigurationValidationError{}
  114. // Validate checks the field values on ScopedRouteConfiguration_Key with the
  115. // rules defined in the proto definition for this message. If any rules are
  116. // violated, an error is returned.
  117. func (m *ScopedRouteConfiguration_Key) Validate() error {
  118. if m == nil {
  119. return nil
  120. }
  121. if len(m.GetFragments()) < 1 {
  122. return ScopedRouteConfiguration_KeyValidationError{
  123. field: "Fragments",
  124. reason: "value must contain at least 1 item(s)",
  125. }
  126. }
  127. for idx, item := range m.GetFragments() {
  128. _, _ = idx, item
  129. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  130. if err := v.Validate(); err != nil {
  131. return ScopedRouteConfiguration_KeyValidationError{
  132. field: fmt.Sprintf("Fragments[%v]", idx),
  133. reason: "embedded message failed validation",
  134. cause: err,
  135. }
  136. }
  137. }
  138. }
  139. return nil
  140. }
  141. // ScopedRouteConfiguration_KeyValidationError is the validation error returned
  142. // by ScopedRouteConfiguration_Key.Validate if the designated constraints
  143. // aren't met.
  144. type ScopedRouteConfiguration_KeyValidationError struct {
  145. field string
  146. reason string
  147. cause error
  148. key bool
  149. }
  150. // Field function returns field value.
  151. func (e ScopedRouteConfiguration_KeyValidationError) Field() string { return e.field }
  152. // Reason function returns reason value.
  153. func (e ScopedRouteConfiguration_KeyValidationError) Reason() string { return e.reason }
  154. // Cause function returns cause value.
  155. func (e ScopedRouteConfiguration_KeyValidationError) Cause() error { return e.cause }
  156. // Key function returns key value.
  157. func (e ScopedRouteConfiguration_KeyValidationError) Key() bool { return e.key }
  158. // ErrorName returns error name.
  159. func (e ScopedRouteConfiguration_KeyValidationError) ErrorName() string {
  160. return "ScopedRouteConfiguration_KeyValidationError"
  161. }
  162. // Error satisfies the builtin error interface
  163. func (e ScopedRouteConfiguration_KeyValidationError) Error() string {
  164. cause := ""
  165. if e.cause != nil {
  166. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  167. }
  168. key := ""
  169. if e.key {
  170. key = "key for "
  171. }
  172. return fmt.Sprintf(
  173. "invalid %sScopedRouteConfiguration_Key.%s: %s%s",
  174. key,
  175. e.field,
  176. e.reason,
  177. cause)
  178. }
  179. var _ error = ScopedRouteConfiguration_KeyValidationError{}
  180. var _ interface {
  181. Field() string
  182. Reason() string
  183. Key() bool
  184. Cause() error
  185. ErrorName() string
  186. } = ScopedRouteConfiguration_KeyValidationError{}
  187. // Validate checks the field values on ScopedRouteConfiguration_Key_Fragment
  188. // with the rules defined in the proto definition for this message. If any
  189. // rules are violated, an error is returned.
  190. func (m *ScopedRouteConfiguration_Key_Fragment) Validate() error {
  191. if m == nil {
  192. return nil
  193. }
  194. switch m.Type.(type) {
  195. case *ScopedRouteConfiguration_Key_Fragment_StringKey:
  196. // no validation rules for StringKey
  197. default:
  198. return ScopedRouteConfiguration_Key_FragmentValidationError{
  199. field: "Type",
  200. reason: "value is required",
  201. }
  202. }
  203. return nil
  204. }
  205. // ScopedRouteConfiguration_Key_FragmentValidationError is the validation error
  206. // returned by ScopedRouteConfiguration_Key_Fragment.Validate if the
  207. // designated constraints aren't met.
  208. type ScopedRouteConfiguration_Key_FragmentValidationError struct {
  209. field string
  210. reason string
  211. cause error
  212. key bool
  213. }
  214. // Field function returns field value.
  215. func (e ScopedRouteConfiguration_Key_FragmentValidationError) Field() string { return e.field }
  216. // Reason function returns reason value.
  217. func (e ScopedRouteConfiguration_Key_FragmentValidationError) Reason() string { return e.reason }
  218. // Cause function returns cause value.
  219. func (e ScopedRouteConfiguration_Key_FragmentValidationError) Cause() error { return e.cause }
  220. // Key function returns key value.
  221. func (e ScopedRouteConfiguration_Key_FragmentValidationError) Key() bool { return e.key }
  222. // ErrorName returns error name.
  223. func (e ScopedRouteConfiguration_Key_FragmentValidationError) ErrorName() string {
  224. return "ScopedRouteConfiguration_Key_FragmentValidationError"
  225. }
  226. // Error satisfies the builtin error interface
  227. func (e ScopedRouteConfiguration_Key_FragmentValidationError) Error() string {
  228. cause := ""
  229. if e.cause != nil {
  230. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  231. }
  232. key := ""
  233. if e.key {
  234. key = "key for "
  235. }
  236. return fmt.Sprintf(
  237. "invalid %sScopedRouteConfiguration_Key_Fragment.%s: %s%s",
  238. key,
  239. e.field,
  240. e.reason,
  241. cause)
  242. }
  243. var _ error = ScopedRouteConfiguration_Key_FragmentValidationError{}
  244. var _ interface {
  245. Field() string
  246. Reason() string
  247. Key() bool
  248. Cause() error
  249. ErrorName() string
  250. } = ScopedRouteConfiguration_Key_FragmentValidationError{}