/pkg/api/envoy/type/matcher/value.pb.validate.go

https://github.com/datawire/ambassador · Go · 320 lines · 219 code · 62 blank · 39 comment · 32 complexity · 56bc899dadbca56bd85618afad430551 MD5 · raw file

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