github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/api/v2/core/address.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: envoy/api/v2/core/address.proto 3 4 package envoy_api_v2_core 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 Pipe with the rules defined in the proto 37 // definition for this message. If any rules are violated, an error is returned. 38 func (m *Pipe) Validate() error { 39 if m == nil { 40 return nil 41 } 42 43 if len(m.GetPath()) < 1 { 44 return PipeValidationError{ 45 field: "Path", 46 reason: "value length must be at least 1 bytes", 47 } 48 } 49 50 if m.GetMode() > 511 { 51 return PipeValidationError{ 52 field: "Mode", 53 reason: "value must be less than or equal to 511", 54 } 55 } 56 57 return nil 58 } 59 60 // PipeValidationError is the validation error returned by Pipe.Validate if the 61 // designated constraints aren't met. 62 type PipeValidationError struct { 63 field string 64 reason string 65 cause error 66 key bool 67 } 68 69 // Field function returns field value. 70 func (e PipeValidationError) Field() string { return e.field } 71 72 // Reason function returns reason value. 73 func (e PipeValidationError) Reason() string { return e.reason } 74 75 // Cause function returns cause value. 76 func (e PipeValidationError) Cause() error { return e.cause } 77 78 // Key function returns key value. 79 func (e PipeValidationError) Key() bool { return e.key } 80 81 // ErrorName returns error name. 82 func (e PipeValidationError) ErrorName() string { return "PipeValidationError" } 83 84 // Error satisfies the builtin error interface 85 func (e PipeValidationError) Error() string { 86 cause := "" 87 if e.cause != nil { 88 cause = fmt.Sprintf(" | caused by: %v", e.cause) 89 } 90 91 key := "" 92 if e.key { 93 key = "key for " 94 } 95 96 return fmt.Sprintf( 97 "invalid %sPipe.%s: %s%s", 98 key, 99 e.field, 100 e.reason, 101 cause) 102 } 103 104 var _ error = PipeValidationError{} 105 106 var _ interface { 107 Field() string 108 Reason() string 109 Key() bool 110 Cause() error 111 ErrorName() string 112 } = PipeValidationError{} 113 114 // Validate checks the field values on SocketAddress with the rules defined in 115 // the proto definition for this message. If any rules are violated, an error 116 // is returned. 117 func (m *SocketAddress) Validate() error { 118 if m == nil { 119 return nil 120 } 121 122 if _, ok := SocketAddress_Protocol_name[int32(m.GetProtocol())]; !ok { 123 return SocketAddressValidationError{ 124 field: "Protocol", 125 reason: "value must be one of the defined enum values", 126 } 127 } 128 129 if len(m.GetAddress()) < 1 { 130 return SocketAddressValidationError{ 131 field: "Address", 132 reason: "value length must be at least 1 bytes", 133 } 134 } 135 136 // no validation rules for ResolverName 137 138 // no validation rules for Ipv4Compat 139 140 switch m.PortSpecifier.(type) { 141 142 case *SocketAddress_PortValue: 143 144 if m.GetPortValue() > 65535 { 145 return SocketAddressValidationError{ 146 field: "PortValue", 147 reason: "value must be less than or equal to 65535", 148 } 149 } 150 151 case *SocketAddress_NamedPort: 152 // no validation rules for NamedPort 153 154 default: 155 return SocketAddressValidationError{ 156 field: "PortSpecifier", 157 reason: "value is required", 158 } 159 160 } 161 162 return nil 163 } 164 165 // SocketAddressValidationError is the validation error returned by 166 // SocketAddress.Validate if the designated constraints aren't met. 167 type SocketAddressValidationError struct { 168 field string 169 reason string 170 cause error 171 key bool 172 } 173 174 // Field function returns field value. 175 func (e SocketAddressValidationError) Field() string { return e.field } 176 177 // Reason function returns reason value. 178 func (e SocketAddressValidationError) Reason() string { return e.reason } 179 180 // Cause function returns cause value. 181 func (e SocketAddressValidationError) Cause() error { return e.cause } 182 183 // Key function returns key value. 184 func (e SocketAddressValidationError) Key() bool { return e.key } 185 186 // ErrorName returns error name. 187 func (e SocketAddressValidationError) ErrorName() string { return "SocketAddressValidationError" } 188 189 // Error satisfies the builtin error interface 190 func (e SocketAddressValidationError) Error() string { 191 cause := "" 192 if e.cause != nil { 193 cause = fmt.Sprintf(" | caused by: %v", e.cause) 194 } 195 196 key := "" 197 if e.key { 198 key = "key for " 199 } 200 201 return fmt.Sprintf( 202 "invalid %sSocketAddress.%s: %s%s", 203 key, 204 e.field, 205 e.reason, 206 cause) 207 } 208 209 var _ error = SocketAddressValidationError{} 210 211 var _ interface { 212 Field() string 213 Reason() string 214 Key() bool 215 Cause() error 216 ErrorName() string 217 } = SocketAddressValidationError{} 218 219 // Validate checks the field values on TcpKeepalive with the rules defined in 220 // the proto definition for this message. If any rules are violated, an error 221 // is returned. 222 func (m *TcpKeepalive) Validate() error { 223 if m == nil { 224 return nil 225 } 226 227 if v, ok := interface{}(m.GetKeepaliveProbes()).(interface{ Validate() error }); ok { 228 if err := v.Validate(); err != nil { 229 return TcpKeepaliveValidationError{ 230 field: "KeepaliveProbes", 231 reason: "embedded message failed validation", 232 cause: err, 233 } 234 } 235 } 236 237 if v, ok := interface{}(m.GetKeepaliveTime()).(interface{ Validate() error }); ok { 238 if err := v.Validate(); err != nil { 239 return TcpKeepaliveValidationError{ 240 field: "KeepaliveTime", 241 reason: "embedded message failed validation", 242 cause: err, 243 } 244 } 245 } 246 247 if v, ok := interface{}(m.GetKeepaliveInterval()).(interface{ Validate() error }); ok { 248 if err := v.Validate(); err != nil { 249 return TcpKeepaliveValidationError{ 250 field: "KeepaliveInterval", 251 reason: "embedded message failed validation", 252 cause: err, 253 } 254 } 255 } 256 257 return nil 258 } 259 260 // TcpKeepaliveValidationError is the validation error returned by 261 // TcpKeepalive.Validate if the designated constraints aren't met. 262 type TcpKeepaliveValidationError struct { 263 field string 264 reason string 265 cause error 266 key bool 267 } 268 269 // Field function returns field value. 270 func (e TcpKeepaliveValidationError) Field() string { return e.field } 271 272 // Reason function returns reason value. 273 func (e TcpKeepaliveValidationError) Reason() string { return e.reason } 274 275 // Cause function returns cause value. 276 func (e TcpKeepaliveValidationError) Cause() error { return e.cause } 277 278 // Key function returns key value. 279 func (e TcpKeepaliveValidationError) Key() bool { return e.key } 280 281 // ErrorName returns error name. 282 func (e TcpKeepaliveValidationError) ErrorName() string { return "TcpKeepaliveValidationError" } 283 284 // Error satisfies the builtin error interface 285 func (e TcpKeepaliveValidationError) Error() string { 286 cause := "" 287 if e.cause != nil { 288 cause = fmt.Sprintf(" | caused by: %v", e.cause) 289 } 290 291 key := "" 292 if e.key { 293 key = "key for " 294 } 295 296 return fmt.Sprintf( 297 "invalid %sTcpKeepalive.%s: %s%s", 298 key, 299 e.field, 300 e.reason, 301 cause) 302 } 303 304 var _ error = TcpKeepaliveValidationError{} 305 306 var _ interface { 307 Field() string 308 Reason() string 309 Key() bool 310 Cause() error 311 ErrorName() string 312 } = TcpKeepaliveValidationError{} 313 314 // Validate checks the field values on BindConfig with the rules defined in the 315 // proto definition for this message. If any rules are violated, an error is returned. 316 func (m *BindConfig) Validate() error { 317 if m == nil { 318 return nil 319 } 320 321 if m.GetSourceAddress() == nil { 322 return BindConfigValidationError{ 323 field: "SourceAddress", 324 reason: "value is required", 325 } 326 } 327 328 if v, ok := interface{}(m.GetSourceAddress()).(interface{ Validate() error }); ok { 329 if err := v.Validate(); err != nil { 330 return BindConfigValidationError{ 331 field: "SourceAddress", 332 reason: "embedded message failed validation", 333 cause: err, 334 } 335 } 336 } 337 338 if v, ok := interface{}(m.GetFreebind()).(interface{ Validate() error }); ok { 339 if err := v.Validate(); err != nil { 340 return BindConfigValidationError{ 341 field: "Freebind", 342 reason: "embedded message failed validation", 343 cause: err, 344 } 345 } 346 } 347 348 for idx, item := range m.GetSocketOptions() { 349 _, _ = idx, item 350 351 if v, ok := interface{}(item).(interface{ Validate() error }); ok { 352 if err := v.Validate(); err != nil { 353 return BindConfigValidationError{ 354 field: fmt.Sprintf("SocketOptions[%v]", idx), 355 reason: "embedded message failed validation", 356 cause: err, 357 } 358 } 359 } 360 361 } 362 363 return nil 364 } 365 366 // BindConfigValidationError is the validation error returned by 367 // BindConfig.Validate if the designated constraints aren't met. 368 type BindConfigValidationError struct { 369 field string 370 reason string 371 cause error 372 key bool 373 } 374 375 // Field function returns field value. 376 func (e BindConfigValidationError) Field() string { return e.field } 377 378 // Reason function returns reason value. 379 func (e BindConfigValidationError) Reason() string { return e.reason } 380 381 // Cause function returns cause value. 382 func (e BindConfigValidationError) Cause() error { return e.cause } 383 384 // Key function returns key value. 385 func (e BindConfigValidationError) Key() bool { return e.key } 386 387 // ErrorName returns error name. 388 func (e BindConfigValidationError) ErrorName() string { return "BindConfigValidationError" } 389 390 // Error satisfies the builtin error interface 391 func (e BindConfigValidationError) Error() string { 392 cause := "" 393 if e.cause != nil { 394 cause = fmt.Sprintf(" | caused by: %v", e.cause) 395 } 396 397 key := "" 398 if e.key { 399 key = "key for " 400 } 401 402 return fmt.Sprintf( 403 "invalid %sBindConfig.%s: %s%s", 404 key, 405 e.field, 406 e.reason, 407 cause) 408 } 409 410 var _ error = BindConfigValidationError{} 411 412 var _ interface { 413 Field() string 414 Reason() string 415 Key() bool 416 Cause() error 417 ErrorName() string 418 } = BindConfigValidationError{} 419 420 // Validate checks the field values on Address with the rules defined in the 421 // proto definition for this message. If any rules are violated, an error is returned. 422 func (m *Address) Validate() error { 423 if m == nil { 424 return nil 425 } 426 427 switch m.Address.(type) { 428 429 case *Address_SocketAddress: 430 431 if v, ok := interface{}(m.GetSocketAddress()).(interface{ Validate() error }); ok { 432 if err := v.Validate(); err != nil { 433 return AddressValidationError{ 434 field: "SocketAddress", 435 reason: "embedded message failed validation", 436 cause: err, 437 } 438 } 439 } 440 441 case *Address_Pipe: 442 443 if v, ok := interface{}(m.GetPipe()).(interface{ Validate() error }); ok { 444 if err := v.Validate(); err != nil { 445 return AddressValidationError{ 446 field: "Pipe", 447 reason: "embedded message failed validation", 448 cause: err, 449 } 450 } 451 } 452 453 default: 454 return AddressValidationError{ 455 field: "Address", 456 reason: "value is required", 457 } 458 459 } 460 461 return nil 462 } 463 464 // AddressValidationError is the validation error returned by Address.Validate 465 // if the designated constraints aren't met. 466 type AddressValidationError struct { 467 field string 468 reason string 469 cause error 470 key bool 471 } 472 473 // Field function returns field value. 474 func (e AddressValidationError) Field() string { return e.field } 475 476 // Reason function returns reason value. 477 func (e AddressValidationError) Reason() string { return e.reason } 478 479 // Cause function returns cause value. 480 func (e AddressValidationError) Cause() error { return e.cause } 481 482 // Key function returns key value. 483 func (e AddressValidationError) Key() bool { return e.key } 484 485 // ErrorName returns error name. 486 func (e AddressValidationError) ErrorName() string { return "AddressValidationError" } 487 488 // Error satisfies the builtin error interface 489 func (e AddressValidationError) Error() string { 490 cause := "" 491 if e.cause != nil { 492 cause = fmt.Sprintf(" | caused by: %v", e.cause) 493 } 494 495 key := "" 496 if e.key { 497 key = "key for " 498 } 499 500 return fmt.Sprintf( 501 "invalid %sAddress.%s: %s%s", 502 key, 503 e.field, 504 e.reason, 505 cause) 506 } 507 508 var _ error = AddressValidationError{} 509 510 var _ interface { 511 Field() string 512 Reason() string 513 Key() bool 514 Cause() error 515 ErrorName() string 516 } = AddressValidationError{} 517 518 // Validate checks the field values on CidrRange with the rules defined in the 519 // proto definition for this message. If any rules are violated, an error is returned. 520 func (m *CidrRange) Validate() error { 521 if m == nil { 522 return nil 523 } 524 525 if len(m.GetAddressPrefix()) < 1 { 526 return CidrRangeValidationError{ 527 field: "AddressPrefix", 528 reason: "value length must be at least 1 bytes", 529 } 530 } 531 532 if wrapper := m.GetPrefixLen(); wrapper != nil { 533 534 if wrapper.GetValue() > 128 { 535 return CidrRangeValidationError{ 536 field: "PrefixLen", 537 reason: "value must be less than or equal to 128", 538 } 539 } 540 541 } 542 543 return nil 544 } 545 546 // CidrRangeValidationError is the validation error returned by 547 // CidrRange.Validate if the designated constraints aren't met. 548 type CidrRangeValidationError struct { 549 field string 550 reason string 551 cause error 552 key bool 553 } 554 555 // Field function returns field value. 556 func (e CidrRangeValidationError) Field() string { return e.field } 557 558 // Reason function returns reason value. 559 func (e CidrRangeValidationError) Reason() string { return e.reason } 560 561 // Cause function returns cause value. 562 func (e CidrRangeValidationError) Cause() error { return e.cause } 563 564 // Key function returns key value. 565 func (e CidrRangeValidationError) Key() bool { return e.key } 566 567 // ErrorName returns error name. 568 func (e CidrRangeValidationError) ErrorName() string { return "CidrRangeValidationError" } 569 570 // Error satisfies the builtin error interface 571 func (e CidrRangeValidationError) Error() string { 572 cause := "" 573 if e.cause != nil { 574 cause = fmt.Sprintf(" | caused by: %v", e.cause) 575 } 576 577 key := "" 578 if e.key { 579 key = "key for " 580 } 581 582 return fmt.Sprintf( 583 "invalid %sCidrRange.%s: %s%s", 584 key, 585 e.field, 586 e.reason, 587 cause) 588 } 589 590 var _ error = CidrRangeValidationError{} 591 592 var _ interface { 593 Field() string 594 Reason() string 595 Key() bool 596 Cause() error 597 ErrorName() string 598 } = CidrRangeValidationError{}