/pkg/api/envoy/extensions/filters/http/lua/v3/lua.pb.validate.go

https://github.com/datawire/ambassador · Go · 218 lines · 149 code · 43 blank · 26 comment · 19 complexity · 7082922852a26954505f209593c44e84 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/extensions/filters/http/lua/v3/lua.proto
  3. package envoy_extensions_filters_http_lua_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 _lua_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 Lua with the rules defined in the proto
  34. // definition for this message. If any rules are violated, an error is returned.
  35. func (m *Lua) Validate() error {
  36. if m == nil {
  37. return nil
  38. }
  39. if len(m.GetInlineCode()) < 1 {
  40. return LuaValidationError{
  41. field: "InlineCode",
  42. reason: "value length must be at least 1 bytes",
  43. }
  44. }
  45. for key, val := range m.GetSourceCodes() {
  46. _ = val
  47. // no validation rules for SourceCodes[key]
  48. if v, ok := interface{}(val).(interface{ Validate() error }); ok {
  49. if err := v.Validate(); err != nil {
  50. return LuaValidationError{
  51. field: fmt.Sprintf("SourceCodes[%v]", key),
  52. reason: "embedded message failed validation",
  53. cause: err,
  54. }
  55. }
  56. }
  57. }
  58. return nil
  59. }
  60. // LuaValidationError is the validation error returned by Lua.Validate if the
  61. // designated constraints aren't met.
  62. type LuaValidationError struct {
  63. field string
  64. reason string
  65. cause error
  66. key bool
  67. }
  68. // Field function returns field value.
  69. func (e LuaValidationError) Field() string { return e.field }
  70. // Reason function returns reason value.
  71. func (e LuaValidationError) Reason() string { return e.reason }
  72. // Cause function returns cause value.
  73. func (e LuaValidationError) Cause() error { return e.cause }
  74. // Key function returns key value.
  75. func (e LuaValidationError) Key() bool { return e.key }
  76. // ErrorName returns error name.
  77. func (e LuaValidationError) ErrorName() string { return "LuaValidationError" }
  78. // Error satisfies the builtin error interface
  79. func (e LuaValidationError) Error() string {
  80. cause := ""
  81. if e.cause != nil {
  82. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  83. }
  84. key := ""
  85. if e.key {
  86. key = "key for "
  87. }
  88. return fmt.Sprintf(
  89. "invalid %sLua.%s: %s%s",
  90. key,
  91. e.field,
  92. e.reason,
  93. cause)
  94. }
  95. var _ error = LuaValidationError{}
  96. var _ interface {
  97. Field() string
  98. Reason() string
  99. Key() bool
  100. Cause() error
  101. ErrorName() string
  102. } = LuaValidationError{}
  103. // Validate checks the field values on LuaPerRoute with the rules defined in
  104. // the proto definition for this message. If any rules are violated, an error
  105. // is returned.
  106. func (m *LuaPerRoute) Validate() error {
  107. if m == nil {
  108. return nil
  109. }
  110. switch m.Override.(type) {
  111. case *LuaPerRoute_Disabled:
  112. if m.GetDisabled() != true {
  113. return LuaPerRouteValidationError{
  114. field: "Disabled",
  115. reason: "value must equal true",
  116. }
  117. }
  118. case *LuaPerRoute_Name:
  119. if utf8.RuneCountInString(m.GetName()) < 1 {
  120. return LuaPerRouteValidationError{
  121. field: "Name",
  122. reason: "value length must be at least 1 runes",
  123. }
  124. }
  125. default:
  126. return LuaPerRouteValidationError{
  127. field: "Override",
  128. reason: "value is required",
  129. }
  130. }
  131. return nil
  132. }
  133. // LuaPerRouteValidationError is the validation error returned by
  134. // LuaPerRoute.Validate if the designated constraints aren't met.
  135. type LuaPerRouteValidationError struct {
  136. field string
  137. reason string
  138. cause error
  139. key bool
  140. }
  141. // Field function returns field value.
  142. func (e LuaPerRouteValidationError) Field() string { return e.field }
  143. // Reason function returns reason value.
  144. func (e LuaPerRouteValidationError) Reason() string { return e.reason }
  145. // Cause function returns cause value.
  146. func (e LuaPerRouteValidationError) Cause() error { return e.cause }
  147. // Key function returns key value.
  148. func (e LuaPerRouteValidationError) Key() bool { return e.key }
  149. // ErrorName returns error name.
  150. func (e LuaPerRouteValidationError) ErrorName() string { return "LuaPerRouteValidationError" }
  151. // Error satisfies the builtin error interface
  152. func (e LuaPerRouteValidationError) Error() string {
  153. cause := ""
  154. if e.cause != nil {
  155. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  156. }
  157. key := ""
  158. if e.key {
  159. key = "key for "
  160. }
  161. return fmt.Sprintf(
  162. "invalid %sLuaPerRoute.%s: %s%s",
  163. key,
  164. e.field,
  165. e.reason,
  166. cause)
  167. }
  168. var _ error = LuaPerRouteValidationError{}
  169. var _ interface {
  170. Field() string
  171. Reason() string
  172. Key() bool
  173. Cause() error
  174. ErrorName() string
  175. } = LuaPerRouteValidationError{}