go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/server/quota/quotapb/ids.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: go.chromium.org/luci/server/quota/quotapb/ids.proto 3 4 package quotapb 5 6 import ( 7 "bytes" 8 "errors" 9 "fmt" 10 "net" 11 "net/mail" 12 "net/url" 13 "regexp" 14 "sort" 15 "strings" 16 "time" 17 "unicode/utf8" 18 19 "google.golang.org/protobuf/types/known/anypb" 20 ) 21 22 // ensure the imports are used 23 var ( 24 _ = bytes.MinRead 25 _ = errors.New("") 26 _ = fmt.Print 27 _ = utf8.UTFMax 28 _ = (*regexp.Regexp)(nil) 29 _ = (*strings.Reader)(nil) 30 _ = net.IPv4len 31 _ = time.Duration(0) 32 _ = (*url.URL)(nil) 33 _ = (*mail.Address)(nil) 34 _ = anypb.Any{} 35 _ = sort.Sort 36 ) 37 38 // Validate checks the field values on PolicyConfigID with the rules defined in 39 // the proto definition for this message. If any rules are violated, the first 40 // error encountered is returned, or nil if there are no violations. 41 func (m *PolicyConfigID) Validate() error { 42 return m.validate(false) 43 } 44 45 // ValidateAll checks the field values on PolicyConfigID with the rules defined 46 // in the proto definition for this message. If any rules are violated, the 47 // result is a list of violation errors wrapped in PolicyConfigIDMultiError, 48 // or nil if none found. 49 func (m *PolicyConfigID) ValidateAll() error { 50 return m.validate(true) 51 } 52 53 func (m *PolicyConfigID) validate(all bool) error { 54 if m == nil { 55 return nil 56 } 57 58 var errors []error 59 60 if strings.Contains(m.GetAppId(), "~") { 61 err := PolicyConfigIDValidationError{ 62 field: "AppId", 63 reason: "value contains substring \"~\"", 64 } 65 if !all { 66 return err 67 } 68 errors = append(errors, err) 69 } 70 71 if strings.Contains(m.GetRealm(), "~") { 72 err := PolicyConfigIDValidationError{ 73 field: "Realm", 74 reason: "value contains substring \"~\"", 75 } 76 if !all { 77 return err 78 } 79 errors = append(errors, err) 80 } 81 82 if m.GetVersionScheme() > 1 { 83 err := PolicyConfigIDValidationError{ 84 field: "VersionScheme", 85 reason: "value must be less than or equal to 1", 86 } 87 if !all { 88 return err 89 } 90 errors = append(errors, err) 91 } 92 93 if strings.Contains(m.GetVersion(), "~") { 94 err := PolicyConfigIDValidationError{ 95 field: "Version", 96 reason: "value contains substring \"~\"", 97 } 98 if !all { 99 return err 100 } 101 errors = append(errors, err) 102 } 103 104 if len(errors) > 0 { 105 return PolicyConfigIDMultiError(errors) 106 } 107 108 return nil 109 } 110 111 // PolicyConfigIDMultiError is an error wrapping multiple validation errors 112 // returned by PolicyConfigID.ValidateAll() if the designated constraints 113 // aren't met. 114 type PolicyConfigIDMultiError []error 115 116 // Error returns a concatenation of all the error messages it wraps. 117 func (m PolicyConfigIDMultiError) Error() string { 118 var msgs []string 119 for _, err := range m { 120 msgs = append(msgs, err.Error()) 121 } 122 return strings.Join(msgs, "; ") 123 } 124 125 // AllErrors returns a list of validation violation errors. 126 func (m PolicyConfigIDMultiError) AllErrors() []error { return m } 127 128 // PolicyConfigIDValidationError is the validation error returned by 129 // PolicyConfigID.Validate if the designated constraints aren't met. 130 type PolicyConfigIDValidationError struct { 131 field string 132 reason string 133 cause error 134 key bool 135 } 136 137 // Field function returns field value. 138 func (e PolicyConfigIDValidationError) Field() string { return e.field } 139 140 // Reason function returns reason value. 141 func (e PolicyConfigIDValidationError) Reason() string { return e.reason } 142 143 // Cause function returns cause value. 144 func (e PolicyConfigIDValidationError) Cause() error { return e.cause } 145 146 // Key function returns key value. 147 func (e PolicyConfigIDValidationError) Key() bool { return e.key } 148 149 // ErrorName returns error name. 150 func (e PolicyConfigIDValidationError) ErrorName() string { return "PolicyConfigIDValidationError" } 151 152 // Error satisfies the builtin error interface 153 func (e PolicyConfigIDValidationError) Error() string { 154 cause := "" 155 if e.cause != nil { 156 cause = fmt.Sprintf(" | caused by: %v", e.cause) 157 } 158 159 key := "" 160 if e.key { 161 key = "key for " 162 } 163 164 return fmt.Sprintf( 165 "invalid %sPolicyConfigID.%s: %s%s", 166 key, 167 e.field, 168 e.reason, 169 cause) 170 } 171 172 var _ error = PolicyConfigIDValidationError{} 173 174 var _ interface { 175 Field() string 176 Reason() string 177 Key() bool 178 Cause() error 179 ErrorName() string 180 } = PolicyConfigIDValidationError{} 181 182 // Validate checks the field values on PolicyID with the rules defined in the 183 // proto definition for this message. If any rules are violated, the first 184 // error encountered is returned, or nil if there are no violations. 185 func (m *PolicyID) Validate() error { 186 return m.validate(false) 187 } 188 189 // ValidateAll checks the field values on PolicyID with the rules defined in 190 // the proto definition for this message. If any rules are violated, the 191 // result is a list of violation errors wrapped in PolicyIDMultiError, or nil 192 // if none found. 193 func (m *PolicyID) ValidateAll() error { 194 return m.validate(true) 195 } 196 197 func (m *PolicyID) validate(all bool) error { 198 if m == nil { 199 return nil 200 } 201 202 var errors []error 203 204 if m.GetConfig() == nil { 205 err := PolicyIDValidationError{ 206 field: "Config", 207 reason: "value is required", 208 } 209 if !all { 210 return err 211 } 212 errors = append(errors, err) 213 } 214 215 if all { 216 switch v := interface{}(m.GetConfig()).(type) { 217 case interface{ ValidateAll() error }: 218 if err := v.ValidateAll(); err != nil { 219 errors = append(errors, PolicyIDValidationError{ 220 field: "Config", 221 reason: "embedded message failed validation", 222 cause: err, 223 }) 224 } 225 case interface{ Validate() error }: 226 if err := v.Validate(); err != nil { 227 errors = append(errors, PolicyIDValidationError{ 228 field: "Config", 229 reason: "embedded message failed validation", 230 cause: err, 231 }) 232 } 233 } 234 } else if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok { 235 if err := v.Validate(); err != nil { 236 return PolicyIDValidationError{ 237 field: "Config", 238 reason: "embedded message failed validation", 239 cause: err, 240 } 241 } 242 } 243 244 if m.GetKey() == nil { 245 err := PolicyIDValidationError{ 246 field: "Key", 247 reason: "value is required", 248 } 249 if !all { 250 return err 251 } 252 errors = append(errors, err) 253 } 254 255 if all { 256 switch v := interface{}(m.GetKey()).(type) { 257 case interface{ ValidateAll() error }: 258 if err := v.ValidateAll(); err != nil { 259 errors = append(errors, PolicyIDValidationError{ 260 field: "Key", 261 reason: "embedded message failed validation", 262 cause: err, 263 }) 264 } 265 case interface{ Validate() error }: 266 if err := v.Validate(); err != nil { 267 errors = append(errors, PolicyIDValidationError{ 268 field: "Key", 269 reason: "embedded message failed validation", 270 cause: err, 271 }) 272 } 273 } 274 } else if v, ok := interface{}(m.GetKey()).(interface{ Validate() error }); ok { 275 if err := v.Validate(); err != nil { 276 return PolicyIDValidationError{ 277 field: "Key", 278 reason: "embedded message failed validation", 279 cause: err, 280 } 281 } 282 } 283 284 if len(errors) > 0 { 285 return PolicyIDMultiError(errors) 286 } 287 288 return nil 289 } 290 291 // PolicyIDMultiError is an error wrapping multiple validation errors returned 292 // by PolicyID.ValidateAll() if the designated constraints aren't met. 293 type PolicyIDMultiError []error 294 295 // Error returns a concatenation of all the error messages it wraps. 296 func (m PolicyIDMultiError) Error() string { 297 var msgs []string 298 for _, err := range m { 299 msgs = append(msgs, err.Error()) 300 } 301 return strings.Join(msgs, "; ") 302 } 303 304 // AllErrors returns a list of validation violation errors. 305 func (m PolicyIDMultiError) AllErrors() []error { return m } 306 307 // PolicyIDValidationError is the validation error returned by 308 // PolicyID.Validate if the designated constraints aren't met. 309 type PolicyIDValidationError struct { 310 field string 311 reason string 312 cause error 313 key bool 314 } 315 316 // Field function returns field value. 317 func (e PolicyIDValidationError) Field() string { return e.field } 318 319 // Reason function returns reason value. 320 func (e PolicyIDValidationError) Reason() string { return e.reason } 321 322 // Cause function returns cause value. 323 func (e PolicyIDValidationError) Cause() error { return e.cause } 324 325 // Key function returns key value. 326 func (e PolicyIDValidationError) Key() bool { return e.key } 327 328 // ErrorName returns error name. 329 func (e PolicyIDValidationError) ErrorName() string { return "PolicyIDValidationError" } 330 331 // Error satisfies the builtin error interface 332 func (e PolicyIDValidationError) Error() string { 333 cause := "" 334 if e.cause != nil { 335 cause = fmt.Sprintf(" | caused by: %v", e.cause) 336 } 337 338 key := "" 339 if e.key { 340 key = "key for " 341 } 342 343 return fmt.Sprintf( 344 "invalid %sPolicyID.%s: %s%s", 345 key, 346 e.field, 347 e.reason, 348 cause) 349 } 350 351 var _ error = PolicyIDValidationError{} 352 353 var _ interface { 354 Field() string 355 Reason() string 356 Key() bool 357 Cause() error 358 ErrorName() string 359 } = PolicyIDValidationError{} 360 361 // Validate checks the field values on PolicyRef with the rules defined in the 362 // proto definition for this message. If any rules are violated, the first 363 // error encountered is returned, or nil if there are no violations. 364 func (m *PolicyRef) Validate() error { 365 return m.validate(false) 366 } 367 368 // ValidateAll checks the field values on PolicyRef with the rules defined in 369 // the proto definition for this message. If any rules are violated, the 370 // result is a list of violation errors wrapped in PolicyRefMultiError, or nil 371 // if none found. 372 func (m *PolicyRef) ValidateAll() error { 373 return m.validate(true) 374 } 375 376 func (m *PolicyRef) validate(all bool) error { 377 if m == nil { 378 return nil 379 } 380 381 var errors []error 382 383 // no validation rules for Config 384 385 // no validation rules for Key 386 387 if len(errors) > 0 { 388 return PolicyRefMultiError(errors) 389 } 390 391 return nil 392 } 393 394 // PolicyRefMultiError is an error wrapping multiple validation errors returned 395 // by PolicyRef.ValidateAll() if the designated constraints aren't met. 396 type PolicyRefMultiError []error 397 398 // Error returns a concatenation of all the error messages it wraps. 399 func (m PolicyRefMultiError) Error() string { 400 var msgs []string 401 for _, err := range m { 402 msgs = append(msgs, err.Error()) 403 } 404 return strings.Join(msgs, "; ") 405 } 406 407 // AllErrors returns a list of validation violation errors. 408 func (m PolicyRefMultiError) AllErrors() []error { return m } 409 410 // PolicyRefValidationError is the validation error returned by 411 // PolicyRef.Validate if the designated constraints aren't met. 412 type PolicyRefValidationError struct { 413 field string 414 reason string 415 cause error 416 key bool 417 } 418 419 // Field function returns field value. 420 func (e PolicyRefValidationError) Field() string { return e.field } 421 422 // Reason function returns reason value. 423 func (e PolicyRefValidationError) Reason() string { return e.reason } 424 425 // Cause function returns cause value. 426 func (e PolicyRefValidationError) Cause() error { return e.cause } 427 428 // Key function returns key value. 429 func (e PolicyRefValidationError) Key() bool { return e.key } 430 431 // ErrorName returns error name. 432 func (e PolicyRefValidationError) ErrorName() string { return "PolicyRefValidationError" } 433 434 // Error satisfies the builtin error interface 435 func (e PolicyRefValidationError) Error() string { 436 cause := "" 437 if e.cause != nil { 438 cause = fmt.Sprintf(" | caused by: %v", e.cause) 439 } 440 441 key := "" 442 if e.key { 443 key = "key for " 444 } 445 446 return fmt.Sprintf( 447 "invalid %sPolicyRef.%s: %s%s", 448 key, 449 e.field, 450 e.reason, 451 cause) 452 } 453 454 var _ error = PolicyRefValidationError{} 455 456 var _ interface { 457 Field() string 458 Reason() string 459 Key() bool 460 Cause() error 461 ErrorName() string 462 } = PolicyRefValidationError{} 463 464 // Validate checks the field values on PolicyKey with the rules defined in the 465 // proto definition for this message. If any rules are violated, the first 466 // error encountered is returned, or nil if there are no violations. 467 func (m *PolicyKey) Validate() error { 468 return m.validate(false) 469 } 470 471 // ValidateAll checks the field values on PolicyKey with the rules defined in 472 // the proto definition for this message. If any rules are violated, the 473 // result is a list of violation errors wrapped in PolicyKeyMultiError, or nil 474 // if none found. 475 func (m *PolicyKey) ValidateAll() error { 476 return m.validate(true) 477 } 478 479 func (m *PolicyKey) validate(all bool) error { 480 if m == nil { 481 return nil 482 } 483 484 var errors []error 485 486 if strings.Contains(m.GetNamespace(), "~") { 487 err := PolicyKeyValidationError{ 488 field: "Namespace", 489 reason: "value contains substring \"~\"", 490 } 491 if !all { 492 return err 493 } 494 errors = append(errors, err) 495 } 496 497 if strings.Contains(m.GetName(), "~") { 498 err := PolicyKeyValidationError{ 499 field: "Name", 500 reason: "value contains substring \"~\"", 501 } 502 if !all { 503 return err 504 } 505 errors = append(errors, err) 506 } 507 508 if strings.Contains(m.GetResourceType(), "~") { 509 err := PolicyKeyValidationError{ 510 field: "ResourceType", 511 reason: "value contains substring \"~\"", 512 } 513 if !all { 514 return err 515 } 516 errors = append(errors, err) 517 } 518 519 if len(errors) > 0 { 520 return PolicyKeyMultiError(errors) 521 } 522 523 return nil 524 } 525 526 // PolicyKeyMultiError is an error wrapping multiple validation errors returned 527 // by PolicyKey.ValidateAll() if the designated constraints aren't met. 528 type PolicyKeyMultiError []error 529 530 // Error returns a concatenation of all the error messages it wraps. 531 func (m PolicyKeyMultiError) Error() string { 532 var msgs []string 533 for _, err := range m { 534 msgs = append(msgs, err.Error()) 535 } 536 return strings.Join(msgs, "; ") 537 } 538 539 // AllErrors returns a list of validation violation errors. 540 func (m PolicyKeyMultiError) AllErrors() []error { return m } 541 542 // PolicyKeyValidationError is the validation error returned by 543 // PolicyKey.Validate if the designated constraints aren't met. 544 type PolicyKeyValidationError struct { 545 field string 546 reason string 547 cause error 548 key bool 549 } 550 551 // Field function returns field value. 552 func (e PolicyKeyValidationError) Field() string { return e.field } 553 554 // Reason function returns reason value. 555 func (e PolicyKeyValidationError) Reason() string { return e.reason } 556 557 // Cause function returns cause value. 558 func (e PolicyKeyValidationError) Cause() error { return e.cause } 559 560 // Key function returns key value. 561 func (e PolicyKeyValidationError) Key() bool { return e.key } 562 563 // ErrorName returns error name. 564 func (e PolicyKeyValidationError) ErrorName() string { return "PolicyKeyValidationError" } 565 566 // Error satisfies the builtin error interface 567 func (e PolicyKeyValidationError) Error() string { 568 cause := "" 569 if e.cause != nil { 570 cause = fmt.Sprintf(" | caused by: %v", e.cause) 571 } 572 573 key := "" 574 if e.key { 575 key = "key for " 576 } 577 578 return fmt.Sprintf( 579 "invalid %sPolicyKey.%s: %s%s", 580 key, 581 e.field, 582 e.reason, 583 cause) 584 } 585 586 var _ error = PolicyKeyValidationError{} 587 588 var _ interface { 589 Field() string 590 Reason() string 591 Key() bool 592 Cause() error 593 ErrorName() string 594 } = PolicyKeyValidationError{} 595 596 // Validate checks the field values on AccountID with the rules defined in the 597 // proto definition for this message. If any rules are violated, the first 598 // error encountered is returned, or nil if there are no violations. 599 func (m *AccountID) Validate() error { 600 return m.validate(false) 601 } 602 603 // ValidateAll checks the field values on AccountID with the rules defined in 604 // the proto definition for this message. If any rules are violated, the 605 // result is a list of violation errors wrapped in AccountIDMultiError, or nil 606 // if none found. 607 func (m *AccountID) ValidateAll() error { 608 return m.validate(true) 609 } 610 611 func (m *AccountID) validate(all bool) error { 612 if m == nil { 613 return nil 614 } 615 616 var errors []error 617 618 if strings.Contains(m.GetAppId(), "~") { 619 err := AccountIDValidationError{ 620 field: "AppId", 621 reason: "value contains substring \"~\"", 622 } 623 if !all { 624 return err 625 } 626 errors = append(errors, err) 627 } 628 629 if strings.Contains(m.GetRealm(), "~") { 630 err := AccountIDValidationError{ 631 field: "Realm", 632 reason: "value contains substring \"~\"", 633 } 634 if !all { 635 return err 636 } 637 errors = append(errors, err) 638 } 639 640 if strings.Contains(m.GetIdentity(), "~") { 641 err := AccountIDValidationError{ 642 field: "Identity", 643 reason: "value contains substring \"~\"", 644 } 645 if !all { 646 return err 647 } 648 errors = append(errors, err) 649 } 650 651 if strings.Contains(m.GetNamespace(), "~") { 652 err := AccountIDValidationError{ 653 field: "Namespace", 654 reason: "value contains substring \"~\"", 655 } 656 if !all { 657 return err 658 } 659 errors = append(errors, err) 660 } 661 662 if strings.Contains(m.GetName(), "~") { 663 err := AccountIDValidationError{ 664 field: "Name", 665 reason: "value contains substring \"~\"", 666 } 667 if !all { 668 return err 669 } 670 errors = append(errors, err) 671 } 672 673 if strings.Contains(m.GetResourceType(), "~") { 674 err := AccountIDValidationError{ 675 field: "ResourceType", 676 reason: "value contains substring \"~\"", 677 } 678 if !all { 679 return err 680 } 681 errors = append(errors, err) 682 } 683 684 if len(errors) > 0 { 685 return AccountIDMultiError(errors) 686 } 687 688 return nil 689 } 690 691 // AccountIDMultiError is an error wrapping multiple validation errors returned 692 // by AccountID.ValidateAll() if the designated constraints aren't met. 693 type AccountIDMultiError []error 694 695 // Error returns a concatenation of all the error messages it wraps. 696 func (m AccountIDMultiError) Error() string { 697 var msgs []string 698 for _, err := range m { 699 msgs = append(msgs, err.Error()) 700 } 701 return strings.Join(msgs, "; ") 702 } 703 704 // AllErrors returns a list of validation violation errors. 705 func (m AccountIDMultiError) AllErrors() []error { return m } 706 707 // AccountIDValidationError is the validation error returned by 708 // AccountID.Validate if the designated constraints aren't met. 709 type AccountIDValidationError struct { 710 field string 711 reason string 712 cause error 713 key bool 714 } 715 716 // Field function returns field value. 717 func (e AccountIDValidationError) Field() string { return e.field } 718 719 // Reason function returns reason value. 720 func (e AccountIDValidationError) Reason() string { return e.reason } 721 722 // Cause function returns cause value. 723 func (e AccountIDValidationError) Cause() error { return e.cause } 724 725 // Key function returns key value. 726 func (e AccountIDValidationError) Key() bool { return e.key } 727 728 // ErrorName returns error name. 729 func (e AccountIDValidationError) ErrorName() string { return "AccountIDValidationError" } 730 731 // Error satisfies the builtin error interface 732 func (e AccountIDValidationError) Error() string { 733 cause := "" 734 if e.cause != nil { 735 cause = fmt.Sprintf(" | caused by: %v", e.cause) 736 } 737 738 key := "" 739 if e.key { 740 key = "key for " 741 } 742 743 return fmt.Sprintf( 744 "invalid %sAccountID.%s: %s%s", 745 key, 746 e.field, 747 e.reason, 748 cause) 749 } 750 751 var _ error = AccountIDValidationError{} 752 753 var _ interface { 754 Field() string 755 Reason() string 756 Key() bool 757 Cause() error 758 ErrorName() string 759 } = AccountIDValidationError{}