/vendor/github.com/envoyproxy/go-control-plane/envoy/type/tracing/v2/custom_tag.pb.validate.go

https://github.com/alipay/sofa-mosn · Go · 479 lines · 328 code · 90 blank · 61 comment · 48 complexity · dc4483c69dbc5c4e736d79f1e52434d0 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/type/tracing/v2/custom_tag.proto
  3. package envoy_type_tracing_v2
  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. // no validation rules for DefaultValue
  272. return nil
  273. }
  274. // CustomTag_HeaderValidationError is the validation error returned by
  275. // CustomTag_Header.Validate if the designated constraints aren't met.
  276. type CustomTag_HeaderValidationError struct {
  277. field string
  278. reason string
  279. cause error
  280. key bool
  281. }
  282. // Field function returns field value.
  283. func (e CustomTag_HeaderValidationError) Field() string { return e.field }
  284. // Reason function returns reason value.
  285. func (e CustomTag_HeaderValidationError) Reason() string { return e.reason }
  286. // Cause function returns cause value.
  287. func (e CustomTag_HeaderValidationError) Cause() error { return e.cause }
  288. // Key function returns key value.
  289. func (e CustomTag_HeaderValidationError) Key() bool { return e.key }
  290. // ErrorName returns error name.
  291. func (e CustomTag_HeaderValidationError) ErrorName() string { return "CustomTag_HeaderValidationError" }
  292. // Error satisfies the builtin error interface
  293. func (e CustomTag_HeaderValidationError) Error() string {
  294. cause := ""
  295. if e.cause != nil {
  296. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  297. }
  298. key := ""
  299. if e.key {
  300. key = "key for "
  301. }
  302. return fmt.Sprintf(
  303. "invalid %sCustomTag_Header.%s: %s%s",
  304. key,
  305. e.field,
  306. e.reason,
  307. cause)
  308. }
  309. var _ error = CustomTag_HeaderValidationError{}
  310. var _ interface {
  311. Field() string
  312. Reason() string
  313. Key() bool
  314. Cause() error
  315. ErrorName() string
  316. } = CustomTag_HeaderValidationError{}
  317. // Validate checks the field values on CustomTag_Metadata with the rules
  318. // defined in the proto definition for this message. If any rules are
  319. // violated, an error is returned.
  320. func (m *CustomTag_Metadata) Validate() error {
  321. if m == nil {
  322. return nil
  323. }
  324. if v, ok := interface{}(m.GetKind()).(interface{ Validate() error }); ok {
  325. if err := v.Validate(); err != nil {
  326. return CustomTag_MetadataValidationError{
  327. field: "Kind",
  328. reason: "embedded message failed validation",
  329. cause: err,
  330. }
  331. }
  332. }
  333. if v, ok := interface{}(m.GetMetadataKey()).(interface{ Validate() error }); ok {
  334. if err := v.Validate(); err != nil {
  335. return CustomTag_MetadataValidationError{
  336. field: "MetadataKey",
  337. reason: "embedded message failed validation",
  338. cause: err,
  339. }
  340. }
  341. }
  342. // no validation rules for DefaultValue
  343. return nil
  344. }
  345. // CustomTag_MetadataValidationError is the validation error returned by
  346. // CustomTag_Metadata.Validate if the designated constraints aren't met.
  347. type CustomTag_MetadataValidationError struct {
  348. field string
  349. reason string
  350. cause error
  351. key bool
  352. }
  353. // Field function returns field value.
  354. func (e CustomTag_MetadataValidationError) Field() string { return e.field }
  355. // Reason function returns reason value.
  356. func (e CustomTag_MetadataValidationError) Reason() string { return e.reason }
  357. // Cause function returns cause value.
  358. func (e CustomTag_MetadataValidationError) Cause() error { return e.cause }
  359. // Key function returns key value.
  360. func (e CustomTag_MetadataValidationError) Key() bool { return e.key }
  361. // ErrorName returns error name.
  362. func (e CustomTag_MetadataValidationError) ErrorName() string {
  363. return "CustomTag_MetadataValidationError"
  364. }
  365. // Error satisfies the builtin error interface
  366. func (e CustomTag_MetadataValidationError) Error() string {
  367. cause := ""
  368. if e.cause != nil {
  369. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  370. }
  371. key := ""
  372. if e.key {
  373. key = "key for "
  374. }
  375. return fmt.Sprintf(
  376. "invalid %sCustomTag_Metadata.%s: %s%s",
  377. key,
  378. e.field,
  379. e.reason,
  380. cause)
  381. }
  382. var _ error = CustomTag_MetadataValidationError{}
  383. var _ interface {
  384. Field() string
  385. Reason() string
  386. Key() bool
  387. Cause() error
  388. ErrorName() string
  389. } = CustomTag_MetadataValidationError{}