/pkg/api/envoy/type/matcher/node.pb.validate.go

https://github.com/datawire/ambassador · Go · 127 lines · 90 code · 22 blank · 15 comment · 12 complexity · a9e3a1e6aa87aba9cbb7c8e8b2a49b00 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/type/matcher/node.proto
  3. package envoy_type_matcher
  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 _node_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 NodeMatcher with the rules defined in
  34. // the proto definition for this message. If any rules are violated, an error
  35. // is returned.
  36. func (m *NodeMatcher) Validate() error {
  37. if m == nil {
  38. return nil
  39. }
  40. if v, ok := interface{}(m.GetNodeId()).(interface{ Validate() error }); ok {
  41. if err := v.Validate(); err != nil {
  42. return NodeMatcherValidationError{
  43. field: "NodeId",
  44. reason: "embedded message failed validation",
  45. cause: err,
  46. }
  47. }
  48. }
  49. for idx, item := range m.GetNodeMetadatas() {
  50. _, _ = idx, item
  51. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  52. if err := v.Validate(); err != nil {
  53. return NodeMatcherValidationError{
  54. field: fmt.Sprintf("NodeMetadatas[%v]", idx),
  55. reason: "embedded message failed validation",
  56. cause: err,
  57. }
  58. }
  59. }
  60. }
  61. return nil
  62. }
  63. // NodeMatcherValidationError is the validation error returned by
  64. // NodeMatcher.Validate if the designated constraints aren't met.
  65. type NodeMatcherValidationError struct {
  66. field string
  67. reason string
  68. cause error
  69. key bool
  70. }
  71. // Field function returns field value.
  72. func (e NodeMatcherValidationError) Field() string { return e.field }
  73. // Reason function returns reason value.
  74. func (e NodeMatcherValidationError) Reason() string { return e.reason }
  75. // Cause function returns cause value.
  76. func (e NodeMatcherValidationError) Cause() error { return e.cause }
  77. // Key function returns key value.
  78. func (e NodeMatcherValidationError) Key() bool { return e.key }
  79. // ErrorName returns error name.
  80. func (e NodeMatcherValidationError) ErrorName() string { return "NodeMatcherValidationError" }
  81. // Error satisfies the builtin error interface
  82. func (e NodeMatcherValidationError) Error() string {
  83. cause := ""
  84. if e.cause != nil {
  85. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  86. }
  87. key := ""
  88. if e.key {
  89. key = "key for "
  90. }
  91. return fmt.Sprintf(
  92. "invalid %sNodeMatcher.%s: %s%s",
  93. key,
  94. e.field,
  95. e.reason,
  96. cause)
  97. }
  98. var _ error = NodeMatcherValidationError{}
  99. var _ interface {
  100. Field() string
  101. Reason() string
  102. Key() bool
  103. Cause() error
  104. ErrorName() string
  105. } = NodeMatcherValidationError{}