gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/go-control-plane/envoy/extensions/access_loggers/file/v3/file.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: envoy/extensions/access_loggers/file/v3/file.proto 3 4 package envoy_extensions_access_loggers_file_v3 5 6 import ( 7 "bytes" 8 "errors" 9 "fmt" 10 "net" 11 "net/mail" 12 "net/url" 13 "regexp" 14 "strings" 15 "time" 16 "unicode/utf8" 17 18 "google.golang.org/protobuf/types/known/anypb" 19 ) 20 21 // ensure the imports are used 22 var ( 23 _ = bytes.MinRead 24 _ = errors.New("") 25 _ = fmt.Print 26 _ = utf8.UTFMax 27 _ = (*regexp.Regexp)(nil) 28 _ = (*strings.Reader)(nil) 29 _ = net.IPv4len 30 _ = time.Duration(0) 31 _ = (*url.URL)(nil) 32 _ = (*mail.Address)(nil) 33 _ = anypb.Any{} 34 ) 35 36 // Validate checks the field values on FileAccessLog with the rules defined in 37 // the proto definition for this message. If any rules are violated, an error 38 // is returned. 39 func (m *FileAccessLog) Validate() error { 40 if m == nil { 41 return nil 42 } 43 44 if utf8.RuneCountInString(m.GetPath()) < 1 { 45 return FileAccessLogValidationError{ 46 field: "Path", 47 reason: "value length must be at least 1 runes", 48 } 49 } 50 51 switch m.AccessLogFormat.(type) { 52 53 case *FileAccessLog_Format: 54 // no validation rules for Format 55 56 case *FileAccessLog_JsonFormat: 57 58 if v, ok := interface{}(m.GetJsonFormat()).(interface{ Validate() error }); ok { 59 if err := v.Validate(); err != nil { 60 return FileAccessLogValidationError{ 61 field: "JsonFormat", 62 reason: "embedded message failed validation", 63 cause: err, 64 } 65 } 66 } 67 68 case *FileAccessLog_TypedJsonFormat: 69 70 if v, ok := interface{}(m.GetTypedJsonFormat()).(interface{ Validate() error }); ok { 71 if err := v.Validate(); err != nil { 72 return FileAccessLogValidationError{ 73 field: "TypedJsonFormat", 74 reason: "embedded message failed validation", 75 cause: err, 76 } 77 } 78 } 79 80 case *FileAccessLog_LogFormat: 81 82 if m.GetLogFormat() == nil { 83 return FileAccessLogValidationError{ 84 field: "LogFormat", 85 reason: "value is required", 86 } 87 } 88 89 if v, ok := interface{}(m.GetLogFormat()).(interface{ Validate() error }); ok { 90 if err := v.Validate(); err != nil { 91 return FileAccessLogValidationError{ 92 field: "LogFormat", 93 reason: "embedded message failed validation", 94 cause: err, 95 } 96 } 97 } 98 99 } 100 101 return nil 102 } 103 104 // FileAccessLogValidationError is the validation error returned by 105 // FileAccessLog.Validate if the designated constraints aren't met. 106 type FileAccessLogValidationError struct { 107 field string 108 reason string 109 cause error 110 key bool 111 } 112 113 // Field function returns field value. 114 func (e FileAccessLogValidationError) Field() string { return e.field } 115 116 // Reason function returns reason value. 117 func (e FileAccessLogValidationError) Reason() string { return e.reason } 118 119 // Cause function returns cause value. 120 func (e FileAccessLogValidationError) Cause() error { return e.cause } 121 122 // Key function returns key value. 123 func (e FileAccessLogValidationError) Key() bool { return e.key } 124 125 // ErrorName returns error name. 126 func (e FileAccessLogValidationError) ErrorName() string { return "FileAccessLogValidationError" } 127 128 // Error satisfies the builtin error interface 129 func (e FileAccessLogValidationError) Error() string { 130 cause := "" 131 if e.cause != nil { 132 cause = fmt.Sprintf(" | caused by: %v", e.cause) 133 } 134 135 key := "" 136 if e.key { 137 key = "key for " 138 } 139 140 return fmt.Sprintf( 141 "invalid %sFileAccessLog.%s: %s%s", 142 key, 143 e.field, 144 e.reason, 145 cause) 146 } 147 148 var _ error = FileAccessLogValidationError{} 149 150 var _ interface { 151 Field() string 152 Reason() string 153 Key() bool 154 Cause() error 155 ErrorName() string 156 } = FileAccessLogValidationError{}