/backend/api/config/service/topology/v1/topology.pb.validate.go

https://github.com/lyft/clutch · Go · 196 lines · 136 code · 36 blank · 24 comment · 18 complexity · e5766cfcea4854d74bff3d7da727df7a MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: config/service/topology/v1/topology.proto
  3. package topologyv1
  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 _topology_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 Config with the rules defined in the
  34. // proto definition for this message. If any rules are violated, an error is returned.
  35. func (m *Config) Validate() error {
  36. if m == nil {
  37. return nil
  38. }
  39. if v, ok := interface{}(m.GetCache()).(interface{ Validate() error }); ok {
  40. if err := v.Validate(); err != nil {
  41. return ConfigValidationError{
  42. field: "Cache",
  43. reason: "embedded message failed validation",
  44. cause: err,
  45. }
  46. }
  47. }
  48. return nil
  49. }
  50. // ConfigValidationError is the validation error returned by Config.Validate if
  51. // the designated constraints aren't met.
  52. type ConfigValidationError struct {
  53. field string
  54. reason string
  55. cause error
  56. key bool
  57. }
  58. // Field function returns field value.
  59. func (e ConfigValidationError) Field() string { return e.field }
  60. // Reason function returns reason value.
  61. func (e ConfigValidationError) Reason() string { return e.reason }
  62. // Cause function returns cause value.
  63. func (e ConfigValidationError) Cause() error { return e.cause }
  64. // Key function returns key value.
  65. func (e ConfigValidationError) Key() bool { return e.key }
  66. // ErrorName returns error name.
  67. func (e ConfigValidationError) ErrorName() string { return "ConfigValidationError" }
  68. // Error satisfies the builtin error interface
  69. func (e ConfigValidationError) Error() string {
  70. cause := ""
  71. if e.cause != nil {
  72. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  73. }
  74. key := ""
  75. if e.key {
  76. key = "key for "
  77. }
  78. return fmt.Sprintf(
  79. "invalid %sConfig.%s: %s%s",
  80. key,
  81. e.field,
  82. e.reason,
  83. cause)
  84. }
  85. var _ error = ConfigValidationError{}
  86. var _ interface {
  87. Field() string
  88. Reason() string
  89. Key() bool
  90. Cause() error
  91. ErrorName() string
  92. } = ConfigValidationError{}
  93. // Validate checks the field values on Cache with the rules defined in the
  94. // proto definition for this message. If any rules are violated, an error is returned.
  95. func (m *Cache) Validate() error {
  96. if m == nil {
  97. return nil
  98. }
  99. if d := m.GetTtl(); d != nil {
  100. dur, err := ptypes.Duration(d)
  101. if err != nil {
  102. return CacheValidationError{
  103. field: "Ttl",
  104. reason: "value is not a valid duration",
  105. cause: err,
  106. }
  107. }
  108. gt := time.Duration(1*time.Second + 0*time.Nanosecond)
  109. if dur <= gt {
  110. return CacheValidationError{
  111. field: "Ttl",
  112. reason: "value must be greater than 1s",
  113. }
  114. }
  115. }
  116. return nil
  117. }
  118. // CacheValidationError is the validation error returned by Cache.Validate if
  119. // the designated constraints aren't met.
  120. type CacheValidationError struct {
  121. field string
  122. reason string
  123. cause error
  124. key bool
  125. }
  126. // Field function returns field value.
  127. func (e CacheValidationError) Field() string { return e.field }
  128. // Reason function returns reason value.
  129. func (e CacheValidationError) Reason() string { return e.reason }
  130. // Cause function returns cause value.
  131. func (e CacheValidationError) Cause() error { return e.cause }
  132. // Key function returns key value.
  133. func (e CacheValidationError) Key() bool { return e.key }
  134. // ErrorName returns error name.
  135. func (e CacheValidationError) ErrorName() string { return "CacheValidationError" }
  136. // Error satisfies the builtin error interface
  137. func (e CacheValidationError) Error() string {
  138. cause := ""
  139. if e.cause != nil {
  140. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  141. }
  142. key := ""
  143. if e.key {
  144. key = "key for "
  145. }
  146. return fmt.Sprintf(
  147. "invalid %sCache.%s: %s%s",
  148. key,
  149. e.field,
  150. e.reason,
  151. cause)
  152. }
  153. var _ error = CacheValidationError{}
  154. var _ interface {
  155. Field() string
  156. Reason() string
  157. Key() bool
  158. Cause() error
  159. ErrorName() string
  160. } = CacheValidationError{}