/pkg/api/envoy/data/dns/v4alpha/dns_table.pb.validate.go

https://github.com/datawire/ambassador · Go · 430 lines · 300 code · 82 blank · 48 comment · 46 complexity · 8b8d87b9349ef9638d1acef8dd9d0d70 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/data/dns/v4alpha/dns_table.proto
  3. package envoy_data_dns_v4alpha
  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 _dns_table_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 DnsTable with the rules defined in the
  34. // proto definition for this message. If any rules are violated, an error is returned.
  35. func (m *DnsTable) Validate() error {
  36. if m == nil {
  37. return nil
  38. }
  39. if m.GetExternalRetryCount() > 3 {
  40. return DnsTableValidationError{
  41. field: "ExternalRetryCount",
  42. reason: "value must be less than or equal to 3",
  43. }
  44. }
  45. for idx, item := range m.GetVirtualDomains() {
  46. _, _ = idx, item
  47. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  48. if err := v.Validate(); err != nil {
  49. return DnsTableValidationError{
  50. field: fmt.Sprintf("VirtualDomains[%v]", idx),
  51. reason: "embedded message failed validation",
  52. cause: err,
  53. }
  54. }
  55. }
  56. }
  57. for idx, item := range m.GetKnownSuffixes() {
  58. _, _ = idx, item
  59. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  60. if err := v.Validate(); err != nil {
  61. return DnsTableValidationError{
  62. field: fmt.Sprintf("KnownSuffixes[%v]", idx),
  63. reason: "embedded message failed validation",
  64. cause: err,
  65. }
  66. }
  67. }
  68. }
  69. return nil
  70. }
  71. // DnsTableValidationError is the validation error returned by
  72. // DnsTable.Validate if the designated constraints aren't met.
  73. type DnsTableValidationError struct {
  74. field string
  75. reason string
  76. cause error
  77. key bool
  78. }
  79. // Field function returns field value.
  80. func (e DnsTableValidationError) Field() string { return e.field }
  81. // Reason function returns reason value.
  82. func (e DnsTableValidationError) Reason() string { return e.reason }
  83. // Cause function returns cause value.
  84. func (e DnsTableValidationError) Cause() error { return e.cause }
  85. // Key function returns key value.
  86. func (e DnsTableValidationError) Key() bool { return e.key }
  87. // ErrorName returns error name.
  88. func (e DnsTableValidationError) ErrorName() string { return "DnsTableValidationError" }
  89. // Error satisfies the builtin error interface
  90. func (e DnsTableValidationError) Error() string {
  91. cause := ""
  92. if e.cause != nil {
  93. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  94. }
  95. key := ""
  96. if e.key {
  97. key = "key for "
  98. }
  99. return fmt.Sprintf(
  100. "invalid %sDnsTable.%s: %s%s",
  101. key,
  102. e.field,
  103. e.reason,
  104. cause)
  105. }
  106. var _ error = DnsTableValidationError{}
  107. var _ interface {
  108. Field() string
  109. Reason() string
  110. Key() bool
  111. Cause() error
  112. ErrorName() string
  113. } = DnsTableValidationError{}
  114. // Validate checks the field values on DnsTable_AddressList with the rules
  115. // defined in the proto definition for this message. If any rules are
  116. // violated, an error is returned.
  117. func (m *DnsTable_AddressList) Validate() error {
  118. if m == nil {
  119. return nil
  120. }
  121. if len(m.GetAddress()) < 1 {
  122. return DnsTable_AddressListValidationError{
  123. field: "Address",
  124. reason: "value must contain at least 1 item(s)",
  125. }
  126. }
  127. for idx, item := range m.GetAddress() {
  128. _, _ = idx, item
  129. if utf8.RuneCountInString(item) < 3 {
  130. return DnsTable_AddressListValidationError{
  131. field: fmt.Sprintf("Address[%v]", idx),
  132. reason: "value length must be at least 3 runes",
  133. }
  134. }
  135. }
  136. return nil
  137. }
  138. // DnsTable_AddressListValidationError is the validation error returned by
  139. // DnsTable_AddressList.Validate if the designated constraints aren't met.
  140. type DnsTable_AddressListValidationError struct {
  141. field string
  142. reason string
  143. cause error
  144. key bool
  145. }
  146. // Field function returns field value.
  147. func (e DnsTable_AddressListValidationError) Field() string { return e.field }
  148. // Reason function returns reason value.
  149. func (e DnsTable_AddressListValidationError) Reason() string { return e.reason }
  150. // Cause function returns cause value.
  151. func (e DnsTable_AddressListValidationError) Cause() error { return e.cause }
  152. // Key function returns key value.
  153. func (e DnsTable_AddressListValidationError) Key() bool { return e.key }
  154. // ErrorName returns error name.
  155. func (e DnsTable_AddressListValidationError) ErrorName() string {
  156. return "DnsTable_AddressListValidationError"
  157. }
  158. // Error satisfies the builtin error interface
  159. func (e DnsTable_AddressListValidationError) Error() string {
  160. cause := ""
  161. if e.cause != nil {
  162. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  163. }
  164. key := ""
  165. if e.key {
  166. key = "key for "
  167. }
  168. return fmt.Sprintf(
  169. "invalid %sDnsTable_AddressList.%s: %s%s",
  170. key,
  171. e.field,
  172. e.reason,
  173. cause)
  174. }
  175. var _ error = DnsTable_AddressListValidationError{}
  176. var _ interface {
  177. Field() string
  178. Reason() string
  179. Key() bool
  180. Cause() error
  181. ErrorName() string
  182. } = DnsTable_AddressListValidationError{}
  183. // Validate checks the field values on DnsTable_DnsEndpoint with the rules
  184. // defined in the proto definition for this message. If any rules are
  185. // violated, an error is returned.
  186. func (m *DnsTable_DnsEndpoint) Validate() error {
  187. if m == nil {
  188. return nil
  189. }
  190. switch m.EndpointConfig.(type) {
  191. case *DnsTable_DnsEndpoint_AddressList:
  192. if v, ok := interface{}(m.GetAddressList()).(interface{ Validate() error }); ok {
  193. if err := v.Validate(); err != nil {
  194. return DnsTable_DnsEndpointValidationError{
  195. field: "AddressList",
  196. reason: "embedded message failed validation",
  197. cause: err,
  198. }
  199. }
  200. }
  201. case *DnsTable_DnsEndpoint_ClusterName:
  202. // no validation rules for ClusterName
  203. default:
  204. return DnsTable_DnsEndpointValidationError{
  205. field: "EndpointConfig",
  206. reason: "value is required",
  207. }
  208. }
  209. return nil
  210. }
  211. // DnsTable_DnsEndpointValidationError is the validation error returned by
  212. // DnsTable_DnsEndpoint.Validate if the designated constraints aren't met.
  213. type DnsTable_DnsEndpointValidationError struct {
  214. field string
  215. reason string
  216. cause error
  217. key bool
  218. }
  219. // Field function returns field value.
  220. func (e DnsTable_DnsEndpointValidationError) Field() string { return e.field }
  221. // Reason function returns reason value.
  222. func (e DnsTable_DnsEndpointValidationError) Reason() string { return e.reason }
  223. // Cause function returns cause value.
  224. func (e DnsTable_DnsEndpointValidationError) Cause() error { return e.cause }
  225. // Key function returns key value.
  226. func (e DnsTable_DnsEndpointValidationError) Key() bool { return e.key }
  227. // ErrorName returns error name.
  228. func (e DnsTable_DnsEndpointValidationError) ErrorName() string {
  229. return "DnsTable_DnsEndpointValidationError"
  230. }
  231. // Error satisfies the builtin error interface
  232. func (e DnsTable_DnsEndpointValidationError) Error() string {
  233. cause := ""
  234. if e.cause != nil {
  235. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  236. }
  237. key := ""
  238. if e.key {
  239. key = "key for "
  240. }
  241. return fmt.Sprintf(
  242. "invalid %sDnsTable_DnsEndpoint.%s: %s%s",
  243. key,
  244. e.field,
  245. e.reason,
  246. cause)
  247. }
  248. var _ error = DnsTable_DnsEndpointValidationError{}
  249. var _ interface {
  250. Field() string
  251. Reason() string
  252. Key() bool
  253. Cause() error
  254. ErrorName() string
  255. } = DnsTable_DnsEndpointValidationError{}
  256. // Validate checks the field values on DnsTable_DnsVirtualDomain with the rules
  257. // defined in the proto definition for this message. If any rules are
  258. // violated, an error is returned.
  259. func (m *DnsTable_DnsVirtualDomain) Validate() error {
  260. if m == nil {
  261. return nil
  262. }
  263. if utf8.RuneCountInString(m.GetName()) < 2 {
  264. return DnsTable_DnsVirtualDomainValidationError{
  265. field: "Name",
  266. reason: "value length must be at least 2 runes",
  267. }
  268. }
  269. if !_DnsTable_DnsVirtualDomain_Name_Pattern.MatchString(m.GetName()) {
  270. return DnsTable_DnsVirtualDomainValidationError{
  271. field: "Name",
  272. reason: "value does not match regex pattern \"^:?[0-9a-zA-Z!#$%&'*+-.^_|~`]+$\"",
  273. }
  274. }
  275. if v, ok := interface{}(m.GetEndpoint()).(interface{ Validate() error }); ok {
  276. if err := v.Validate(); err != nil {
  277. return DnsTable_DnsVirtualDomainValidationError{
  278. field: "Endpoint",
  279. reason: "embedded message failed validation",
  280. cause: err,
  281. }
  282. }
  283. }
  284. if d := m.GetAnswerTtl(); d != nil {
  285. dur, err := ptypes.Duration(d)
  286. if err != nil {
  287. return DnsTable_DnsVirtualDomainValidationError{
  288. field: "AnswerTtl",
  289. reason: "value is not a valid duration",
  290. cause: err,
  291. }
  292. }
  293. gte := time.Duration(60*time.Second + 0*time.Nanosecond)
  294. if dur < gte {
  295. return DnsTable_DnsVirtualDomainValidationError{
  296. field: "AnswerTtl",
  297. reason: "value must be greater than or equal to 1m0s",
  298. }
  299. }
  300. }
  301. return nil
  302. }
  303. // DnsTable_DnsVirtualDomainValidationError is the validation error returned by
  304. // DnsTable_DnsVirtualDomain.Validate if the designated constraints aren't met.
  305. type DnsTable_DnsVirtualDomainValidationError struct {
  306. field string
  307. reason string
  308. cause error
  309. key bool
  310. }
  311. // Field function returns field value.
  312. func (e DnsTable_DnsVirtualDomainValidationError) Field() string { return e.field }
  313. // Reason function returns reason value.
  314. func (e DnsTable_DnsVirtualDomainValidationError) Reason() string { return e.reason }
  315. // Cause function returns cause value.
  316. func (e DnsTable_DnsVirtualDomainValidationError) Cause() error { return e.cause }
  317. // Key function returns key value.
  318. func (e DnsTable_DnsVirtualDomainValidationError) Key() bool { return e.key }
  319. // ErrorName returns error name.
  320. func (e DnsTable_DnsVirtualDomainValidationError) ErrorName() string {
  321. return "DnsTable_DnsVirtualDomainValidationError"
  322. }
  323. // Error satisfies the builtin error interface
  324. func (e DnsTable_DnsVirtualDomainValidationError) Error() string {
  325. cause := ""
  326. if e.cause != nil {
  327. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  328. }
  329. key := ""
  330. if e.key {
  331. key = "key for "
  332. }
  333. return fmt.Sprintf(
  334. "invalid %sDnsTable_DnsVirtualDomain.%s: %s%s",
  335. key,
  336. e.field,
  337. e.reason,
  338. cause)
  339. }
  340. var _ error = DnsTable_DnsVirtualDomainValidationError{}
  341. var _ interface {
  342. Field() string
  343. Reason() string
  344. Key() bool
  345. Cause() error
  346. ErrorName() string
  347. } = DnsTable_DnsVirtualDomainValidationError{}
  348. var _DnsTable_DnsVirtualDomain_Name_Pattern = regexp.MustCompile("^:?[0-9a-zA-Z!#$%&'*+-.^_|~`]+$")