gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/go-control-plane/envoy/extensions/common/ratelimit/v3/ratelimit.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: envoy/extensions/common/ratelimit/v3/ratelimit.proto 3 4 package envoy_extensions_common_ratelimit_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 v3 "gitee.com/ks-custle/core-gm/go-control-plane/envoy/type/v3" 21 ) 22 23 // ensure the imports are used 24 var ( 25 _ = bytes.MinRead 26 _ = errors.New("") 27 _ = fmt.Print 28 _ = utf8.UTFMax 29 _ = (*regexp.Regexp)(nil) 30 _ = (*strings.Reader)(nil) 31 _ = net.IPv4len 32 _ = time.Duration(0) 33 _ = (*url.URL)(nil) 34 _ = (*mail.Address)(nil) 35 _ = anypb.Any{} 36 37 _ = v3.RateLimitUnit(0) 38 ) 39 40 // Validate checks the field values on RateLimitDescriptor with the rules 41 // defined in the proto definition for this message. If any rules are 42 // violated, an error is returned. 43 func (m *RateLimitDescriptor) Validate() error { 44 if m == nil { 45 return nil 46 } 47 48 if len(m.GetEntries()) < 1 { 49 return RateLimitDescriptorValidationError{ 50 field: "Entries", 51 reason: "value must contain at least 1 item(s)", 52 } 53 } 54 55 for idx, item := range m.GetEntries() { 56 _, _ = idx, item 57 58 if v, ok := interface{}(item).(interface{ Validate() error }); ok { 59 if err := v.Validate(); err != nil { 60 return RateLimitDescriptorValidationError{ 61 field: fmt.Sprintf("Entries[%v]", idx), 62 reason: "embedded message failed validation", 63 cause: err, 64 } 65 } 66 } 67 68 } 69 70 if v, ok := interface{}(m.GetLimit()).(interface{ Validate() error }); ok { 71 if err := v.Validate(); err != nil { 72 return RateLimitDescriptorValidationError{ 73 field: "Limit", 74 reason: "embedded message failed validation", 75 cause: err, 76 } 77 } 78 } 79 80 return nil 81 } 82 83 // RateLimitDescriptorValidationError is the validation error returned by 84 // RateLimitDescriptor.Validate if the designated constraints aren't met. 85 type RateLimitDescriptorValidationError struct { 86 field string 87 reason string 88 cause error 89 key bool 90 } 91 92 // Field function returns field value. 93 func (e RateLimitDescriptorValidationError) Field() string { return e.field } 94 95 // Reason function returns reason value. 96 func (e RateLimitDescriptorValidationError) Reason() string { return e.reason } 97 98 // Cause function returns cause value. 99 func (e RateLimitDescriptorValidationError) Cause() error { return e.cause } 100 101 // Key function returns key value. 102 func (e RateLimitDescriptorValidationError) Key() bool { return e.key } 103 104 // ErrorName returns error name. 105 func (e RateLimitDescriptorValidationError) ErrorName() string { 106 return "RateLimitDescriptorValidationError" 107 } 108 109 // Error satisfies the builtin error interface 110 func (e RateLimitDescriptorValidationError) Error() string { 111 cause := "" 112 if e.cause != nil { 113 cause = fmt.Sprintf(" | caused by: %v", e.cause) 114 } 115 116 key := "" 117 if e.key { 118 key = "key for " 119 } 120 121 return fmt.Sprintf( 122 "invalid %sRateLimitDescriptor.%s: %s%s", 123 key, 124 e.field, 125 e.reason, 126 cause) 127 } 128 129 var _ error = RateLimitDescriptorValidationError{} 130 131 var _ interface { 132 Field() string 133 Reason() string 134 Key() bool 135 Cause() error 136 ErrorName() string 137 } = RateLimitDescriptorValidationError{} 138 139 // Validate checks the field values on LocalRateLimitDescriptor with the rules 140 // defined in the proto definition for this message. If any rules are 141 // violated, an error is returned. 142 func (m *LocalRateLimitDescriptor) Validate() error { 143 if m == nil { 144 return nil 145 } 146 147 if len(m.GetEntries()) < 1 { 148 return LocalRateLimitDescriptorValidationError{ 149 field: "Entries", 150 reason: "value must contain at least 1 item(s)", 151 } 152 } 153 154 for idx, item := range m.GetEntries() { 155 _, _ = idx, item 156 157 if v, ok := interface{}(item).(interface{ Validate() error }); ok { 158 if err := v.Validate(); err != nil { 159 return LocalRateLimitDescriptorValidationError{ 160 field: fmt.Sprintf("Entries[%v]", idx), 161 reason: "embedded message failed validation", 162 cause: err, 163 } 164 } 165 } 166 167 } 168 169 if m.GetTokenBucket() == nil { 170 return LocalRateLimitDescriptorValidationError{ 171 field: "TokenBucket", 172 reason: "value is required", 173 } 174 } 175 176 if v, ok := interface{}(m.GetTokenBucket()).(interface{ Validate() error }); ok { 177 if err := v.Validate(); err != nil { 178 return LocalRateLimitDescriptorValidationError{ 179 field: "TokenBucket", 180 reason: "embedded message failed validation", 181 cause: err, 182 } 183 } 184 } 185 186 return nil 187 } 188 189 // LocalRateLimitDescriptorValidationError is the validation error returned by 190 // LocalRateLimitDescriptor.Validate if the designated constraints aren't met. 191 type LocalRateLimitDescriptorValidationError struct { 192 field string 193 reason string 194 cause error 195 key bool 196 } 197 198 // Field function returns field value. 199 func (e LocalRateLimitDescriptorValidationError) Field() string { return e.field } 200 201 // Reason function returns reason value. 202 func (e LocalRateLimitDescriptorValidationError) Reason() string { return e.reason } 203 204 // Cause function returns cause value. 205 func (e LocalRateLimitDescriptorValidationError) Cause() error { return e.cause } 206 207 // Key function returns key value. 208 func (e LocalRateLimitDescriptorValidationError) Key() bool { return e.key } 209 210 // ErrorName returns error name. 211 func (e LocalRateLimitDescriptorValidationError) ErrorName() string { 212 return "LocalRateLimitDescriptorValidationError" 213 } 214 215 // Error satisfies the builtin error interface 216 func (e LocalRateLimitDescriptorValidationError) Error() string { 217 cause := "" 218 if e.cause != nil { 219 cause = fmt.Sprintf(" | caused by: %v", e.cause) 220 } 221 222 key := "" 223 if e.key { 224 key = "key for " 225 } 226 227 return fmt.Sprintf( 228 "invalid %sLocalRateLimitDescriptor.%s: %s%s", 229 key, 230 e.field, 231 e.reason, 232 cause) 233 } 234 235 var _ error = LocalRateLimitDescriptorValidationError{} 236 237 var _ interface { 238 Field() string 239 Reason() string 240 Key() bool 241 Cause() error 242 ErrorName() string 243 } = LocalRateLimitDescriptorValidationError{} 244 245 // Validate checks the field values on RateLimitDescriptor_Entry with the rules 246 // defined in the proto definition for this message. If any rules are 247 // violated, an error is returned. 248 func (m *RateLimitDescriptor_Entry) Validate() error { 249 if m == nil { 250 return nil 251 } 252 253 if utf8.RuneCountInString(m.GetKey()) < 1 { 254 return RateLimitDescriptor_EntryValidationError{ 255 field: "Key", 256 reason: "value length must be at least 1 runes", 257 } 258 } 259 260 if utf8.RuneCountInString(m.GetValue()) < 1 { 261 return RateLimitDescriptor_EntryValidationError{ 262 field: "Value", 263 reason: "value length must be at least 1 runes", 264 } 265 } 266 267 return nil 268 } 269 270 // RateLimitDescriptor_EntryValidationError is the validation error returned by 271 // RateLimitDescriptor_Entry.Validate if the designated constraints aren't met. 272 type RateLimitDescriptor_EntryValidationError struct { 273 field string 274 reason string 275 cause error 276 key bool 277 } 278 279 // Field function returns field value. 280 func (e RateLimitDescriptor_EntryValidationError) Field() string { return e.field } 281 282 // Reason function returns reason value. 283 func (e RateLimitDescriptor_EntryValidationError) Reason() string { return e.reason } 284 285 // Cause function returns cause value. 286 func (e RateLimitDescriptor_EntryValidationError) Cause() error { return e.cause } 287 288 // Key function returns key value. 289 func (e RateLimitDescriptor_EntryValidationError) Key() bool { return e.key } 290 291 // ErrorName returns error name. 292 func (e RateLimitDescriptor_EntryValidationError) ErrorName() string { 293 return "RateLimitDescriptor_EntryValidationError" 294 } 295 296 // Error satisfies the builtin error interface 297 func (e RateLimitDescriptor_EntryValidationError) Error() string { 298 cause := "" 299 if e.cause != nil { 300 cause = fmt.Sprintf(" | caused by: %v", e.cause) 301 } 302 303 key := "" 304 if e.key { 305 key = "key for " 306 } 307 308 return fmt.Sprintf( 309 "invalid %sRateLimitDescriptor_Entry.%s: %s%s", 310 key, 311 e.field, 312 e.reason, 313 cause) 314 } 315 316 var _ error = RateLimitDescriptor_EntryValidationError{} 317 318 var _ interface { 319 Field() string 320 Reason() string 321 Key() bool 322 Cause() error 323 ErrorName() string 324 } = RateLimitDescriptor_EntryValidationError{} 325 326 // Validate checks the field values on RateLimitDescriptor_RateLimitOverride 327 // with the rules defined in the proto definition for this message. If any 328 // rules are violated, an error is returned. 329 func (m *RateLimitDescriptor_RateLimitOverride) Validate() error { 330 if m == nil { 331 return nil 332 } 333 334 // no validation rules for RequestsPerUnit 335 336 if _, ok := v3.RateLimitUnit_name[int32(m.GetUnit())]; !ok { 337 return RateLimitDescriptor_RateLimitOverrideValidationError{ 338 field: "Unit", 339 reason: "value must be one of the defined enum values", 340 } 341 } 342 343 return nil 344 } 345 346 // RateLimitDescriptor_RateLimitOverrideValidationError is the validation error 347 // returned by RateLimitDescriptor_RateLimitOverride.Validate if the 348 // designated constraints aren't met. 349 type RateLimitDescriptor_RateLimitOverrideValidationError struct { 350 field string 351 reason string 352 cause error 353 key bool 354 } 355 356 // Field function returns field value. 357 func (e RateLimitDescriptor_RateLimitOverrideValidationError) Field() string { return e.field } 358 359 // Reason function returns reason value. 360 func (e RateLimitDescriptor_RateLimitOverrideValidationError) Reason() string { return e.reason } 361 362 // Cause function returns cause value. 363 func (e RateLimitDescriptor_RateLimitOverrideValidationError) Cause() error { return e.cause } 364 365 // Key function returns key value. 366 func (e RateLimitDescriptor_RateLimitOverrideValidationError) Key() bool { return e.key } 367 368 // ErrorName returns error name. 369 func (e RateLimitDescriptor_RateLimitOverrideValidationError) ErrorName() string { 370 return "RateLimitDescriptor_RateLimitOverrideValidationError" 371 } 372 373 // Error satisfies the builtin error interface 374 func (e RateLimitDescriptor_RateLimitOverrideValidationError) Error() string { 375 cause := "" 376 if e.cause != nil { 377 cause = fmt.Sprintf(" | caused by: %v", e.cause) 378 } 379 380 key := "" 381 if e.key { 382 key = "key for " 383 } 384 385 return fmt.Sprintf( 386 "invalid %sRateLimitDescriptor_RateLimitOverride.%s: %s%s", 387 key, 388 e.field, 389 e.reason, 390 cause) 391 } 392 393 var _ error = RateLimitDescriptor_RateLimitOverrideValidationError{} 394 395 var _ interface { 396 Field() string 397 Reason() string 398 Key() bool 399 Cause() error 400 ErrorName() string 401 } = RateLimitDescriptor_RateLimitOverrideValidationError{}