/pkg/api/envoy/config/core/v4alpha/event_service_config.pb.validate.go

https://github.com/datawire/ambassador · Go · 126 lines · 88 code · 23 blank · 15 comment · 9 complexity · 613a90f614299e8d46310936b1fb87a1 MD5 · raw file

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