/pkg/api/envoy/type/tracing/v3/custom_tag.pb.validate.go

https://github.com/datawire/ambassador · Go · 488 lines · 335 code · 92 blank · 61 comment · 49 complexity · 9e032a1d6527f4f3479253bdb581c1c9 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/type/tracing/v3/custom_tag.proto
  3. package envoy_type_tracing_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 _custom_tag_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 CustomTag with the rules defined in the
  34. // proto definition for this message. If any rules are violated, an error is returned.
  35. func (m *CustomTag) Validate() error {
  36. if m == nil {
  37. return nil
  38. }
  39. if len(m.GetTag()) < 1 {
  40. return CustomTagValidationError{
  41. field: "Tag",
  42. reason: "value length must be at least 1 bytes",
  43. }
  44. }
  45. switch m.Type.(type) {
  46. case *CustomTag_Literal_:
  47. if v, ok := interface{}(m.GetLiteral()).(interface{ Validate() error }); ok {
  48. if err := v.Validate(); err != nil {
  49. return CustomTagValidationError{
  50. field: "Literal",
  51. reason: "embedded message failed validation",
  52. cause: err,
  53. }
  54. }
  55. }
  56. case *CustomTag_Environment_:
  57. if v, ok := interface{}(m.GetEnvironment()).(interface{ Validate() error }); ok {
  58. if err := v.Validate(); err != nil {
  59. return CustomTagValidationError{
  60. field: "Environment",
  61. reason: "embedded message failed validation",
  62. cause: err,
  63. }
  64. }
  65. }
  66. case *CustomTag_RequestHeader:
  67. if v, ok := interface{}(m.GetRequestHeader()).(interface{ Validate() error }); ok {
  68. if err := v.Validate(); err != nil {
  69. return CustomTagValidationError{
  70. field: "RequestHeader",
  71. reason: "embedded message failed validation",
  72. cause: err,
  73. }
  74. }
  75. }
  76. case *CustomTag_Metadata_:
  77. if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok {
  78. if err := v.Validate(); err != nil {
  79. return CustomTagValidationError{
  80. field: "Metadata",
  81. reason: "embedded message failed validation",
  82. cause: err,
  83. }
  84. }
  85. }
  86. default:
  87. return CustomTagValidationError{
  88. field: "Type",
  89. reason: "value is required",
  90. }
  91. }
  92. return nil
  93. }
  94. // CustomTagValidationError is the validation error returned by
  95. // CustomTag.Validate if the designated constraints aren't met.
  96. type CustomTagValidationError struct {
  97. field string
  98. reason string
  99. cause error
  100. key bool
  101. }
  102. // Field function returns field value.
  103. func (e CustomTagValidationError) Field() string { return e.field }
  104. // Reason function returns reason value.
  105. func (e CustomTagValidationError) Reason() string { return e.reason }
  106. // Cause function returns cause value.
  107. func (e CustomTagValidationError) Cause() error { return e.cause }
  108. // Key function returns key value.
  109. func (e CustomTagValidationError) Key() bool { return e.key }
  110. // ErrorName returns error name.
  111. func (e CustomTagValidationError) ErrorName() string { return "CustomTagValidationError" }
  112. // Error satisfies the builtin error interface
  113. func (e CustomTagValidationError) Error() string {
  114. cause := ""
  115. if e.cause != nil {
  116. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  117. }
  118. key := ""
  119. if e.key {
  120. key = "key for "
  121. }
  122. return fmt.Sprintf(
  123. "invalid %sCustomTag.%s: %s%s",
  124. key,
  125. e.field,
  126. e.reason,
  127. cause)
  128. }
  129. var _ error = CustomTagValidationError{}
  130. var _ interface {
  131. Field() string
  132. Reason() string
  133. Key() bool
  134. Cause() error
  135. ErrorName() string
  136. } = CustomTagValidationError{}
  137. // Validate checks the field values on CustomTag_Literal with the rules defined
  138. // in the proto definition for this message. If any rules are violated, an
  139. // error is returned.
  140. func (m *CustomTag_Literal) Validate() error {
  141. if m == nil {
  142. return nil
  143. }
  144. if len(m.GetValue()) < 1 {
  145. return CustomTag_LiteralValidationError{
  146. field: "Value",
  147. reason: "value length must be at least 1 bytes",
  148. }
  149. }
  150. return nil
  151. }
  152. // CustomTag_LiteralValidationError is the validation error returned by
  153. // CustomTag_Literal.Validate if the designated constraints aren't met.
  154. type CustomTag_LiteralValidationError struct {
  155. field string
  156. reason string
  157. cause error
  158. key bool
  159. }
  160. // Field function returns field value.
  161. func (e CustomTag_LiteralValidationError) Field() string { return e.field }
  162. // Reason function returns reason value.
  163. func (e CustomTag_LiteralValidationError) Reason() string { return e.reason }
  164. // Cause function returns cause value.
  165. func (e CustomTag_LiteralValidationError) Cause() error { return e.cause }
  166. // Key function returns key value.
  167. func (e CustomTag_LiteralValidationError) Key() bool { return e.key }
  168. // ErrorName returns error name.
  169. func (e CustomTag_LiteralValidationError) ErrorName() string {
  170. return "CustomTag_LiteralValidationError"
  171. }
  172. // Error satisfies the builtin error interface
  173. func (e CustomTag_LiteralValidationError) Error() string {
  174. cause := ""
  175. if e.cause != nil {
  176. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  177. }
  178. key := ""
  179. if e.key {
  180. key = "key for "
  181. }
  182. return fmt.Sprintf(
  183. "invalid %sCustomTag_Literal.%s: %s%s",
  184. key,
  185. e.field,
  186. e.reason,
  187. cause)
  188. }
  189. var _ error = CustomTag_LiteralValidationError{}
  190. var _ interface {
  191. Field() string
  192. Reason() string
  193. Key() bool
  194. Cause() error
  195. ErrorName() string
  196. } = CustomTag_LiteralValidationError{}
  197. // Validate checks the field values on CustomTag_Environment with the rules
  198. // defined in the proto definition for this message. If any rules are
  199. // violated, an error is returned.
  200. func (m *CustomTag_Environment) Validate() error {
  201. if m == nil {
  202. return nil
  203. }
  204. if len(m.GetName()) < 1 {
  205. return CustomTag_EnvironmentValidationError{
  206. field: "Name",
  207. reason: "value length must be at least 1 bytes",
  208. }
  209. }
  210. // no validation rules for DefaultValue
  211. return nil
  212. }
  213. // CustomTag_EnvironmentValidationError is the validation error returned by
  214. // CustomTag_Environment.Validate if the designated constraints aren't met.
  215. type CustomTag_EnvironmentValidationError struct {
  216. field string
  217. reason string
  218. cause error
  219. key bool
  220. }
  221. // Field function returns field value.
  222. func (e CustomTag_EnvironmentValidationError) Field() string { return e.field }
  223. // Reason function returns reason value.
  224. func (e CustomTag_EnvironmentValidationError) Reason() string { return e.reason }
  225. // Cause function returns cause value.
  226. func (e CustomTag_EnvironmentValidationError) Cause() error { return e.cause }
  227. // Key function returns key value.
  228. func (e CustomTag_EnvironmentValidationError) Key() bool { return e.key }
  229. // ErrorName returns error name.
  230. func (e CustomTag_EnvironmentValidationError) ErrorName() string {
  231. return "CustomTag_EnvironmentValidationError"
  232. }
  233. // Error satisfies the builtin error interface
  234. func (e CustomTag_EnvironmentValidationError) Error() string {
  235. cause := ""
  236. if e.cause != nil {
  237. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  238. }
  239. key := ""
  240. if e.key {
  241. key = "key for "
  242. }
  243. return fmt.Sprintf(
  244. "invalid %sCustomTag_Environment.%s: %s%s",
  245. key,
  246. e.field,
  247. e.reason,
  248. cause)
  249. }
  250. var _ error = CustomTag_EnvironmentValidationError{}
  251. var _ interface {
  252. Field() string
  253. Reason() string
  254. Key() bool
  255. Cause() error
  256. ErrorName() string
  257. } = CustomTag_EnvironmentValidationError{}
  258. // Validate checks the field values on CustomTag_Header with the rules defined
  259. // in the proto definition for this message. If any rules are violated, an
  260. // error is returned.
  261. func (m *CustomTag_Header) Validate() error {
  262. if m == nil {
  263. return nil
  264. }
  265. if len(m.GetName()) < 1 {
  266. return CustomTag_HeaderValidationError{
  267. field: "Name",
  268. reason: "value length must be at least 1 bytes",
  269. }
  270. }
  271. if !_CustomTag_Header_Name_Pattern.MatchString(m.GetName()) {
  272. return CustomTag_HeaderValidationError{
  273. field: "Name",
  274. reason: "value does not match regex pattern \"^[^\\x00\\n\\r]*$\"",
  275. }
  276. }
  277. // no validation rules for DefaultValue
  278. return nil
  279. }
  280. // CustomTag_HeaderValidationError is the validation error returned by
  281. // CustomTag_Header.Validate if the designated constraints aren't met.
  282. type CustomTag_HeaderValidationError struct {
  283. field string
  284. reason string
  285. cause error
  286. key bool
  287. }
  288. // Field function returns field value.
  289. func (e CustomTag_HeaderValidationError) Field() string { return e.field }
  290. // Reason function returns reason value.
  291. func (e CustomTag_HeaderValidationError) Reason() string { return e.reason }
  292. // Cause function returns cause value.
  293. func (e CustomTag_HeaderValidationError) Cause() error { return e.cause }
  294. // Key function returns key value.
  295. func (e CustomTag_HeaderValidationError) Key() bool { return e.key }
  296. // ErrorName returns error name.
  297. func (e CustomTag_HeaderValidationError) ErrorName() string { return "CustomTag_HeaderValidationError" }
  298. // Error satisfies the builtin error interface
  299. func (e CustomTag_HeaderValidationError) Error() string {
  300. cause := ""
  301. if e.cause != nil {
  302. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  303. }
  304. key := ""
  305. if e.key {
  306. key = "key for "
  307. }
  308. return fmt.Sprintf(
  309. "invalid %sCustomTag_Header.%s: %s%s",
  310. key,
  311. e.field,
  312. e.reason,
  313. cause)
  314. }
  315. var _ error = CustomTag_HeaderValidationError{}
  316. var _ interface {
  317. Field() string
  318. Reason() string
  319. Key() bool
  320. Cause() error
  321. ErrorName() string
  322. } = CustomTag_HeaderValidationError{}
  323. var _CustomTag_Header_Name_Pattern = regexp.MustCompile("^[^\x00\n\r]*$")
  324. // Validate checks the field values on CustomTag_Metadata with the rules
  325. // defined in the proto definition for this message. If any rules are
  326. // violated, an error is returned.
  327. func (m *CustomTag_Metadata) Validate() error {
  328. if m == nil {
  329. return nil
  330. }
  331. if v, ok := interface{}(m.GetKind()).(interface{ Validate() error }); ok {
  332. if err := v.Validate(); err != nil {
  333. return CustomTag_MetadataValidationError{
  334. field: "Kind",
  335. reason: "embedded message failed validation",
  336. cause: err,
  337. }
  338. }
  339. }
  340. if v, ok := interface{}(m.GetMetadataKey()).(interface{ Validate() error }); ok {
  341. if err := v.Validate(); err != nil {
  342. return CustomTag_MetadataValidationError{
  343. field: "MetadataKey",
  344. reason: "embedded message failed validation",
  345. cause: err,
  346. }
  347. }
  348. }
  349. // no validation rules for DefaultValue
  350. return nil
  351. }
  352. // CustomTag_MetadataValidationError is the validation error returned by
  353. // CustomTag_Metadata.Validate if the designated constraints aren't met.
  354. type CustomTag_MetadataValidationError struct {
  355. field string
  356. reason string
  357. cause error
  358. key bool
  359. }
  360. // Field function returns field value.
  361. func (e CustomTag_MetadataValidationError) Field() string { return e.field }
  362. // Reason function returns reason value.
  363. func (e CustomTag_MetadataValidationError) Reason() string { return e.reason }
  364. // Cause function returns cause value.
  365. func (e CustomTag_MetadataValidationError) Cause() error { return e.cause }
  366. // Key function returns key value.
  367. func (e CustomTag_MetadataValidationError) Key() bool { return e.key }
  368. // ErrorName returns error name.
  369. func (e CustomTag_MetadataValidationError) ErrorName() string {
  370. return "CustomTag_MetadataValidationError"
  371. }
  372. // Error satisfies the builtin error interface
  373. func (e CustomTag_MetadataValidationError) Error() string {
  374. cause := ""
  375. if e.cause != nil {
  376. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  377. }
  378. key := ""
  379. if e.key {
  380. key = "key for "
  381. }
  382. return fmt.Sprintf(
  383. "invalid %sCustomTag_Metadata.%s: %s%s",
  384. key,
  385. e.field,
  386. e.reason,
  387. cause)
  388. }
  389. var _ error = CustomTag_MetadataValidationError{}
  390. var _ interface {
  391. Field() string
  392. Reason() string
  393. Key() bool
  394. Cause() error
  395. ErrorName() string
  396. } = CustomTag_MetadataValidationError{}