/vendor/github.com/envoyproxy/go-control-plane/envoy/extensions/access_loggers/file/v3/file.pb.validate.go

https://github.com/XiaoMi/naftis · Go · 140 lines · 98 code · 26 blank · 16 comment · 13 complexity · 21c7068c737d5a1fb2f8e08f27979c3f MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/extensions/access_loggers/file/v3/file.proto
  3. package envoy_extensions_access_loggers_file_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 _file_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 FileAccessLog 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 *FileAccessLog) Validate() error {
  37. if m == nil {
  38. return nil
  39. }
  40. if len(m.GetPath()) < 1 {
  41. return FileAccessLogValidationError{
  42. field: "Path",
  43. reason: "value length must be at least 1 bytes",
  44. }
  45. }
  46. switch m.AccessLogFormat.(type) {
  47. case *FileAccessLog_Format:
  48. // no validation rules for Format
  49. case *FileAccessLog_JsonFormat:
  50. if v, ok := interface{}(m.GetJsonFormat()).(interface{ Validate() error }); ok {
  51. if err := v.Validate(); err != nil {
  52. return FileAccessLogValidationError{
  53. field: "JsonFormat",
  54. reason: "embedded message failed validation",
  55. cause: err,
  56. }
  57. }
  58. }
  59. case *FileAccessLog_TypedJsonFormat:
  60. if v, ok := interface{}(m.GetTypedJsonFormat()).(interface{ Validate() error }); ok {
  61. if err := v.Validate(); err != nil {
  62. return FileAccessLogValidationError{
  63. field: "TypedJsonFormat",
  64. reason: "embedded message failed validation",
  65. cause: err,
  66. }
  67. }
  68. }
  69. }
  70. return nil
  71. }
  72. // FileAccessLogValidationError is the validation error returned by
  73. // FileAccessLog.Validate if the designated constraints aren't met.
  74. type FileAccessLogValidationError struct {
  75. field string
  76. reason string
  77. cause error
  78. key bool
  79. }
  80. // Field function returns field value.
  81. func (e FileAccessLogValidationError) Field() string { return e.field }
  82. // Reason function returns reason value.
  83. func (e FileAccessLogValidationError) Reason() string { return e.reason }
  84. // Cause function returns cause value.
  85. func (e FileAccessLogValidationError) Cause() error { return e.cause }
  86. // Key function returns key value.
  87. func (e FileAccessLogValidationError) Key() bool { return e.key }
  88. // ErrorName returns error name.
  89. func (e FileAccessLogValidationError) ErrorName() string { return "FileAccessLogValidationError" }
  90. // Error satisfies the builtin error interface
  91. func (e FileAccessLogValidationError) Error() string {
  92. cause := ""
  93. if e.cause != nil {
  94. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  95. }
  96. key := ""
  97. if e.key {
  98. key = "key for "
  99. }
  100. return fmt.Sprintf(
  101. "invalid %sFileAccessLog.%s: %s%s",
  102. key,
  103. e.field,
  104. e.reason,
  105. cause)
  106. }
  107. var _ error = FileAccessLogValidationError{}
  108. var _ interface {
  109. Field() string
  110. Reason() string
  111. Key() bool
  112. Cause() error
  113. ErrorName() string
  114. } = FileAccessLogValidationError{}