github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/type/matcher/regex.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: envoy/type/matcher/regex.proto 3 4 package envoy_type_matcher 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 RegexMatcher 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 *RegexMatcher) Validate() error { 40 if m == nil { 41 return nil 42 } 43 44 if utf8.RuneCountInString(m.GetRegex()) < 1 { 45 return RegexMatcherValidationError{ 46 field: "Regex", 47 reason: "value length must be at least 1 runes", 48 } 49 } 50 51 switch m.EngineType.(type) { 52 53 case *RegexMatcher_GoogleRe2: 54 55 if m.GetGoogleRe2() == nil { 56 return RegexMatcherValidationError{ 57 field: "GoogleRe2", 58 reason: "value is required", 59 } 60 } 61 62 if v, ok := interface{}(m.GetGoogleRe2()).(interface{ Validate() error }); ok { 63 if err := v.Validate(); err != nil { 64 return RegexMatcherValidationError{ 65 field: "GoogleRe2", 66 reason: "embedded message failed validation", 67 cause: err, 68 } 69 } 70 } 71 72 default: 73 return RegexMatcherValidationError{ 74 field: "EngineType", 75 reason: "value is required", 76 } 77 78 } 79 80 return nil 81 } 82 83 // RegexMatcherValidationError is the validation error returned by 84 // RegexMatcher.Validate if the designated constraints aren't met. 85 type RegexMatcherValidationError struct { 86 field string 87 reason string 88 cause error 89 key bool 90 } 91 92 // Field function returns field value. 93 func (e RegexMatcherValidationError) Field() string { return e.field } 94 95 // Reason function returns reason value. 96 func (e RegexMatcherValidationError) Reason() string { return e.reason } 97 98 // Cause function returns cause value. 99 func (e RegexMatcherValidationError) Cause() error { return e.cause } 100 101 // Key function returns key value. 102 func (e RegexMatcherValidationError) Key() bool { return e.key } 103 104 // ErrorName returns error name. 105 func (e RegexMatcherValidationError) ErrorName() string { return "RegexMatcherValidationError" } 106 107 // Error satisfies the builtin error interface 108 func (e RegexMatcherValidationError) Error() string { 109 cause := "" 110 if e.cause != nil { 111 cause = fmt.Sprintf(" | caused by: %v", e.cause) 112 } 113 114 key := "" 115 if e.key { 116 key = "key for " 117 } 118 119 return fmt.Sprintf( 120 "invalid %sRegexMatcher.%s: %s%s", 121 key, 122 e.field, 123 e.reason, 124 cause) 125 } 126 127 var _ error = RegexMatcherValidationError{} 128 129 var _ interface { 130 Field() string 131 Reason() string 132 Key() bool 133 Cause() error 134 ErrorName() string 135 } = RegexMatcherValidationError{} 136 137 // Validate checks the field values on RegexMatchAndSubstitute with the rules 138 // defined in the proto definition for this message. If any rules are 139 // violated, an error is returned. 140 func (m *RegexMatchAndSubstitute) Validate() error { 141 if m == nil { 142 return nil 143 } 144 145 if v, ok := interface{}(m.GetPattern()).(interface{ Validate() error }); ok { 146 if err := v.Validate(); err != nil { 147 return RegexMatchAndSubstituteValidationError{ 148 field: "Pattern", 149 reason: "embedded message failed validation", 150 cause: err, 151 } 152 } 153 } 154 155 // no validation rules for Substitution 156 157 return nil 158 } 159 160 // RegexMatchAndSubstituteValidationError is the validation error returned by 161 // RegexMatchAndSubstitute.Validate if the designated constraints aren't met. 162 type RegexMatchAndSubstituteValidationError struct { 163 field string 164 reason string 165 cause error 166 key bool 167 } 168 169 // Field function returns field value. 170 func (e RegexMatchAndSubstituteValidationError) Field() string { return e.field } 171 172 // Reason function returns reason value. 173 func (e RegexMatchAndSubstituteValidationError) Reason() string { return e.reason } 174 175 // Cause function returns cause value. 176 func (e RegexMatchAndSubstituteValidationError) Cause() error { return e.cause } 177 178 // Key function returns key value. 179 func (e RegexMatchAndSubstituteValidationError) Key() bool { return e.key } 180 181 // ErrorName returns error name. 182 func (e RegexMatchAndSubstituteValidationError) ErrorName() string { 183 return "RegexMatchAndSubstituteValidationError" 184 } 185 186 // Error satisfies the builtin error interface 187 func (e RegexMatchAndSubstituteValidationError) Error() string { 188 cause := "" 189 if e.cause != nil { 190 cause = fmt.Sprintf(" | caused by: %v", e.cause) 191 } 192 193 key := "" 194 if e.key { 195 key = "key for " 196 } 197 198 return fmt.Sprintf( 199 "invalid %sRegexMatchAndSubstitute.%s: %s%s", 200 key, 201 e.field, 202 e.reason, 203 cause) 204 } 205 206 var _ error = RegexMatchAndSubstituteValidationError{} 207 208 var _ interface { 209 Field() string 210 Reason() string 211 Key() bool 212 Cause() error 213 ErrorName() string 214 } = RegexMatchAndSubstituteValidationError{} 215 216 // Validate checks the field values on RegexMatcher_GoogleRE2 with the rules 217 // defined in the proto definition for this message. If any rules are 218 // violated, an error is returned. 219 func (m *RegexMatcher_GoogleRE2) Validate() error { 220 if m == nil { 221 return nil 222 } 223 224 if v, ok := interface{}(m.GetMaxProgramSize()).(interface{ Validate() error }); ok { 225 if err := v.Validate(); err != nil { 226 return RegexMatcher_GoogleRE2ValidationError{ 227 field: "MaxProgramSize", 228 reason: "embedded message failed validation", 229 cause: err, 230 } 231 } 232 } 233 234 return nil 235 } 236 237 // RegexMatcher_GoogleRE2ValidationError is the validation error returned by 238 // RegexMatcher_GoogleRE2.Validate if the designated constraints aren't met. 239 type RegexMatcher_GoogleRE2ValidationError struct { 240 field string 241 reason string 242 cause error 243 key bool 244 } 245 246 // Field function returns field value. 247 func (e RegexMatcher_GoogleRE2ValidationError) Field() string { return e.field } 248 249 // Reason function returns reason value. 250 func (e RegexMatcher_GoogleRE2ValidationError) Reason() string { return e.reason } 251 252 // Cause function returns cause value. 253 func (e RegexMatcher_GoogleRE2ValidationError) Cause() error { return e.cause } 254 255 // Key function returns key value. 256 func (e RegexMatcher_GoogleRE2ValidationError) Key() bool { return e.key } 257 258 // ErrorName returns error name. 259 func (e RegexMatcher_GoogleRE2ValidationError) ErrorName() string { 260 return "RegexMatcher_GoogleRE2ValidationError" 261 } 262 263 // Error satisfies the builtin error interface 264 func (e RegexMatcher_GoogleRE2ValidationError) Error() string { 265 cause := "" 266 if e.cause != nil { 267 cause = fmt.Sprintf(" | caused by: %v", e.cause) 268 } 269 270 key := "" 271 if e.key { 272 key = "key for " 273 } 274 275 return fmt.Sprintf( 276 "invalid %sRegexMatcher_GoogleRE2.%s: %s%s", 277 key, 278 e.field, 279 e.reason, 280 cause) 281 } 282 283 var _ error = RegexMatcher_GoogleRE2ValidationError{} 284 285 var _ interface { 286 Field() string 287 Reason() string 288 Key() bool 289 Cause() error 290 ErrorName() string 291 } = RegexMatcher_GoogleRE2ValidationError{}