github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/pkg/proto/core/v1/core.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: core/v1/core.proto 3 4 package corev1 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 RelationTuple 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 *RelationTuple) Validate() error { 42 return m.validate(false) 43 } 44 45 // ValidateAll checks the field values on RelationTuple 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 RelationTupleMultiError, or 48 // nil if none found. 49 func (m *RelationTuple) ValidateAll() error { 50 return m.validate(true) 51 } 52 53 func (m *RelationTuple) validate(all bool) error { 54 if m == nil { 55 return nil 56 } 57 58 var errors []error 59 60 if m.GetResourceAndRelation() == nil { 61 err := RelationTupleValidationError{ 62 field: "ResourceAndRelation", 63 reason: "value is required", 64 } 65 if !all { 66 return err 67 } 68 errors = append(errors, err) 69 } 70 71 if all { 72 switch v := interface{}(m.GetResourceAndRelation()).(type) { 73 case interface{ ValidateAll() error }: 74 if err := v.ValidateAll(); err != nil { 75 errors = append(errors, RelationTupleValidationError{ 76 field: "ResourceAndRelation", 77 reason: "embedded message failed validation", 78 cause: err, 79 }) 80 } 81 case interface{ Validate() error }: 82 if err := v.Validate(); err != nil { 83 errors = append(errors, RelationTupleValidationError{ 84 field: "ResourceAndRelation", 85 reason: "embedded message failed validation", 86 cause: err, 87 }) 88 } 89 } 90 } else if v, ok := interface{}(m.GetResourceAndRelation()).(interface{ Validate() error }); ok { 91 if err := v.Validate(); err != nil { 92 return RelationTupleValidationError{ 93 field: "ResourceAndRelation", 94 reason: "embedded message failed validation", 95 cause: err, 96 } 97 } 98 } 99 100 if m.GetSubject() == nil { 101 err := RelationTupleValidationError{ 102 field: "Subject", 103 reason: "value is required", 104 } 105 if !all { 106 return err 107 } 108 errors = append(errors, err) 109 } 110 111 if all { 112 switch v := interface{}(m.GetSubject()).(type) { 113 case interface{ ValidateAll() error }: 114 if err := v.ValidateAll(); err != nil { 115 errors = append(errors, RelationTupleValidationError{ 116 field: "Subject", 117 reason: "embedded message failed validation", 118 cause: err, 119 }) 120 } 121 case interface{ Validate() error }: 122 if err := v.Validate(); err != nil { 123 errors = append(errors, RelationTupleValidationError{ 124 field: "Subject", 125 reason: "embedded message failed validation", 126 cause: err, 127 }) 128 } 129 } 130 } else if v, ok := interface{}(m.GetSubject()).(interface{ Validate() error }); ok { 131 if err := v.Validate(); err != nil { 132 return RelationTupleValidationError{ 133 field: "Subject", 134 reason: "embedded message failed validation", 135 cause: err, 136 } 137 } 138 } 139 140 if all { 141 switch v := interface{}(m.GetCaveat()).(type) { 142 case interface{ ValidateAll() error }: 143 if err := v.ValidateAll(); err != nil { 144 errors = append(errors, RelationTupleValidationError{ 145 field: "Caveat", 146 reason: "embedded message failed validation", 147 cause: err, 148 }) 149 } 150 case interface{ Validate() error }: 151 if err := v.Validate(); err != nil { 152 errors = append(errors, RelationTupleValidationError{ 153 field: "Caveat", 154 reason: "embedded message failed validation", 155 cause: err, 156 }) 157 } 158 } 159 } else if v, ok := interface{}(m.GetCaveat()).(interface{ Validate() error }); ok { 160 if err := v.Validate(); err != nil { 161 return RelationTupleValidationError{ 162 field: "Caveat", 163 reason: "embedded message failed validation", 164 cause: err, 165 } 166 } 167 } 168 169 if len(errors) > 0 { 170 return RelationTupleMultiError(errors) 171 } 172 173 return nil 174 } 175 176 // RelationTupleMultiError is an error wrapping multiple validation errors 177 // returned by RelationTuple.ValidateAll() if the designated constraints 178 // aren't met. 179 type RelationTupleMultiError []error 180 181 // Error returns a concatenation of all the error messages it wraps. 182 func (m RelationTupleMultiError) Error() string { 183 var msgs []string 184 for _, err := range m { 185 msgs = append(msgs, err.Error()) 186 } 187 return strings.Join(msgs, "; ") 188 } 189 190 // AllErrors returns a list of validation violation errors. 191 func (m RelationTupleMultiError) AllErrors() []error { return m } 192 193 // RelationTupleValidationError is the validation error returned by 194 // RelationTuple.Validate if the designated constraints aren't met. 195 type RelationTupleValidationError struct { 196 field string 197 reason string 198 cause error 199 key bool 200 } 201 202 // Field function returns field value. 203 func (e RelationTupleValidationError) Field() string { return e.field } 204 205 // Reason function returns reason value. 206 func (e RelationTupleValidationError) Reason() string { return e.reason } 207 208 // Cause function returns cause value. 209 func (e RelationTupleValidationError) Cause() error { return e.cause } 210 211 // Key function returns key value. 212 func (e RelationTupleValidationError) Key() bool { return e.key } 213 214 // ErrorName returns error name. 215 func (e RelationTupleValidationError) ErrorName() string { return "RelationTupleValidationError" } 216 217 // Error satisfies the builtin error interface 218 func (e RelationTupleValidationError) Error() string { 219 cause := "" 220 if e.cause != nil { 221 cause = fmt.Sprintf(" | caused by: %v", e.cause) 222 } 223 224 key := "" 225 if e.key { 226 key = "key for " 227 } 228 229 return fmt.Sprintf( 230 "invalid %sRelationTuple.%s: %s%s", 231 key, 232 e.field, 233 e.reason, 234 cause) 235 } 236 237 var _ error = RelationTupleValidationError{} 238 239 var _ interface { 240 Field() string 241 Reason() string 242 Key() bool 243 Cause() error 244 ErrorName() string 245 } = RelationTupleValidationError{} 246 247 // Validate checks the field values on ContextualizedCaveat with the rules 248 // defined in the proto definition for this message. If any rules are 249 // violated, the first error encountered is returned, or nil if there are no violations. 250 func (m *ContextualizedCaveat) Validate() error { 251 return m.validate(false) 252 } 253 254 // ValidateAll checks the field values on ContextualizedCaveat with the rules 255 // defined in the proto definition for this message. If any rules are 256 // violated, the result is a list of violation errors wrapped in 257 // ContextualizedCaveatMultiError, or nil if none found. 258 func (m *ContextualizedCaveat) ValidateAll() error { 259 return m.validate(true) 260 } 261 262 func (m *ContextualizedCaveat) validate(all bool) error { 263 if m == nil { 264 return nil 265 } 266 267 var errors []error 268 269 if len(m.GetCaveatName()) > 128 { 270 err := ContextualizedCaveatValidationError{ 271 field: "CaveatName", 272 reason: "value length must be at most 128 bytes", 273 } 274 if !all { 275 return err 276 } 277 errors = append(errors, err) 278 } 279 280 if !_ContextualizedCaveat_CaveatName_Pattern.MatchString(m.GetCaveatName()) { 281 err := ContextualizedCaveatValidationError{ 282 field: "CaveatName", 283 reason: "value does not match regex pattern \"^(([a-zA-Z0-9_][a-zA-Z0-9/_|-]{0,127})|\\\\*)$\"", 284 } 285 if !all { 286 return err 287 } 288 errors = append(errors, err) 289 } 290 291 if all { 292 switch v := interface{}(m.GetContext()).(type) { 293 case interface{ ValidateAll() error }: 294 if err := v.ValidateAll(); err != nil { 295 errors = append(errors, ContextualizedCaveatValidationError{ 296 field: "Context", 297 reason: "embedded message failed validation", 298 cause: err, 299 }) 300 } 301 case interface{ Validate() error }: 302 if err := v.Validate(); err != nil { 303 errors = append(errors, ContextualizedCaveatValidationError{ 304 field: "Context", 305 reason: "embedded message failed validation", 306 cause: err, 307 }) 308 } 309 } 310 } else if v, ok := interface{}(m.GetContext()).(interface{ Validate() error }); ok { 311 if err := v.Validate(); err != nil { 312 return ContextualizedCaveatValidationError{ 313 field: "Context", 314 reason: "embedded message failed validation", 315 cause: err, 316 } 317 } 318 } 319 320 if len(errors) > 0 { 321 return ContextualizedCaveatMultiError(errors) 322 } 323 324 return nil 325 } 326 327 // ContextualizedCaveatMultiError is an error wrapping multiple validation 328 // errors returned by ContextualizedCaveat.ValidateAll() if the designated 329 // constraints aren't met. 330 type ContextualizedCaveatMultiError []error 331 332 // Error returns a concatenation of all the error messages it wraps. 333 func (m ContextualizedCaveatMultiError) Error() string { 334 var msgs []string 335 for _, err := range m { 336 msgs = append(msgs, err.Error()) 337 } 338 return strings.Join(msgs, "; ") 339 } 340 341 // AllErrors returns a list of validation violation errors. 342 func (m ContextualizedCaveatMultiError) AllErrors() []error { return m } 343 344 // ContextualizedCaveatValidationError is the validation error returned by 345 // ContextualizedCaveat.Validate if the designated constraints aren't met. 346 type ContextualizedCaveatValidationError struct { 347 field string 348 reason string 349 cause error 350 key bool 351 } 352 353 // Field function returns field value. 354 func (e ContextualizedCaveatValidationError) Field() string { return e.field } 355 356 // Reason function returns reason value. 357 func (e ContextualizedCaveatValidationError) Reason() string { return e.reason } 358 359 // Cause function returns cause value. 360 func (e ContextualizedCaveatValidationError) Cause() error { return e.cause } 361 362 // Key function returns key value. 363 func (e ContextualizedCaveatValidationError) Key() bool { return e.key } 364 365 // ErrorName returns error name. 366 func (e ContextualizedCaveatValidationError) ErrorName() string { 367 return "ContextualizedCaveatValidationError" 368 } 369 370 // Error satisfies the builtin error interface 371 func (e ContextualizedCaveatValidationError) Error() string { 372 cause := "" 373 if e.cause != nil { 374 cause = fmt.Sprintf(" | caused by: %v", e.cause) 375 } 376 377 key := "" 378 if e.key { 379 key = "key for " 380 } 381 382 return fmt.Sprintf( 383 "invalid %sContextualizedCaveat.%s: %s%s", 384 key, 385 e.field, 386 e.reason, 387 cause) 388 } 389 390 var _ error = ContextualizedCaveatValidationError{} 391 392 var _ interface { 393 Field() string 394 Reason() string 395 Key() bool 396 Cause() error 397 ErrorName() string 398 } = ContextualizedCaveatValidationError{} 399 400 var _ContextualizedCaveat_CaveatName_Pattern = regexp.MustCompile("^(([a-zA-Z0-9_][a-zA-Z0-9/_|-]{0,127})|\\*)$") 401 402 // Validate checks the field values on CaveatDefinition with the rules defined 403 // in the proto definition for this message. If any rules are violated, the 404 // first error encountered is returned, or nil if there are no violations. 405 func (m *CaveatDefinition) Validate() error { 406 return m.validate(false) 407 } 408 409 // ValidateAll checks the field values on CaveatDefinition with the rules 410 // defined in the proto definition for this message. If any rules are 411 // violated, the result is a list of violation errors wrapped in 412 // CaveatDefinitionMultiError, or nil if none found. 413 func (m *CaveatDefinition) ValidateAll() error { 414 return m.validate(true) 415 } 416 417 func (m *CaveatDefinition) validate(all bool) error { 418 if m == nil { 419 return nil 420 } 421 422 var errors []error 423 424 if len(m.GetName()) > 128 { 425 err := CaveatDefinitionValidationError{ 426 field: "Name", 427 reason: "value length must be at most 128 bytes", 428 } 429 if !all { 430 return err 431 } 432 errors = append(errors, err) 433 } 434 435 if !_CaveatDefinition_Name_Pattern.MatchString(m.GetName()) { 436 err := CaveatDefinitionValidationError{ 437 field: "Name", 438 reason: "value does not match regex pattern \"^(([a-zA-Z0-9_][a-zA-Z0-9/_|-]{0,127})|\\\\*)$\"", 439 } 440 if !all { 441 return err 442 } 443 errors = append(errors, err) 444 } 445 446 if l := len(m.GetSerializedExpression()); l < 0 || l > 4096 { 447 err := CaveatDefinitionValidationError{ 448 field: "SerializedExpression", 449 reason: "value length must be between 0 and 4096 bytes, inclusive", 450 } 451 if !all { 452 return err 453 } 454 errors = append(errors, err) 455 } 456 457 if l := len(m.GetParameterTypes()); l < 1 || l > 20 { 458 err := CaveatDefinitionValidationError{ 459 field: "ParameterTypes", 460 reason: "value must contain between 1 and 20 pairs, inclusive", 461 } 462 if !all { 463 return err 464 } 465 errors = append(errors, err) 466 } 467 468 { 469 sorted_keys := make([]string, len(m.GetParameterTypes())) 470 i := 0 471 for key := range m.GetParameterTypes() { 472 sorted_keys[i] = key 473 i++ 474 } 475 sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) 476 for _, key := range sorted_keys { 477 val := m.GetParameterTypes()[key] 478 _ = val 479 480 // no validation rules for ParameterTypes[key] 481 482 if all { 483 switch v := interface{}(val).(type) { 484 case interface{ ValidateAll() error }: 485 if err := v.ValidateAll(); err != nil { 486 errors = append(errors, CaveatDefinitionValidationError{ 487 field: fmt.Sprintf("ParameterTypes[%v]", key), 488 reason: "embedded message failed validation", 489 cause: err, 490 }) 491 } 492 case interface{ Validate() error }: 493 if err := v.Validate(); err != nil { 494 errors = append(errors, CaveatDefinitionValidationError{ 495 field: fmt.Sprintf("ParameterTypes[%v]", key), 496 reason: "embedded message failed validation", 497 cause: err, 498 }) 499 } 500 } 501 } else if v, ok := interface{}(val).(interface{ Validate() error }); ok { 502 if err := v.Validate(); err != nil { 503 return CaveatDefinitionValidationError{ 504 field: fmt.Sprintf("ParameterTypes[%v]", key), 505 reason: "embedded message failed validation", 506 cause: err, 507 } 508 } 509 } 510 511 } 512 } 513 514 if all { 515 switch v := interface{}(m.GetMetadata()).(type) { 516 case interface{ ValidateAll() error }: 517 if err := v.ValidateAll(); err != nil { 518 errors = append(errors, CaveatDefinitionValidationError{ 519 field: "Metadata", 520 reason: "embedded message failed validation", 521 cause: err, 522 }) 523 } 524 case interface{ Validate() error }: 525 if err := v.Validate(); err != nil { 526 errors = append(errors, CaveatDefinitionValidationError{ 527 field: "Metadata", 528 reason: "embedded message failed validation", 529 cause: err, 530 }) 531 } 532 } 533 } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { 534 if err := v.Validate(); err != nil { 535 return CaveatDefinitionValidationError{ 536 field: "Metadata", 537 reason: "embedded message failed validation", 538 cause: err, 539 } 540 } 541 } 542 543 if all { 544 switch v := interface{}(m.GetSourcePosition()).(type) { 545 case interface{ ValidateAll() error }: 546 if err := v.ValidateAll(); err != nil { 547 errors = append(errors, CaveatDefinitionValidationError{ 548 field: "SourcePosition", 549 reason: "embedded message failed validation", 550 cause: err, 551 }) 552 } 553 case interface{ Validate() error }: 554 if err := v.Validate(); err != nil { 555 errors = append(errors, CaveatDefinitionValidationError{ 556 field: "SourcePosition", 557 reason: "embedded message failed validation", 558 cause: err, 559 }) 560 } 561 } 562 } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { 563 if err := v.Validate(); err != nil { 564 return CaveatDefinitionValidationError{ 565 field: "SourcePosition", 566 reason: "embedded message failed validation", 567 cause: err, 568 } 569 } 570 } 571 572 if len(errors) > 0 { 573 return CaveatDefinitionMultiError(errors) 574 } 575 576 return nil 577 } 578 579 // CaveatDefinitionMultiError is an error wrapping multiple validation errors 580 // returned by CaveatDefinition.ValidateAll() if the designated constraints 581 // aren't met. 582 type CaveatDefinitionMultiError []error 583 584 // Error returns a concatenation of all the error messages it wraps. 585 func (m CaveatDefinitionMultiError) Error() string { 586 var msgs []string 587 for _, err := range m { 588 msgs = append(msgs, err.Error()) 589 } 590 return strings.Join(msgs, "; ") 591 } 592 593 // AllErrors returns a list of validation violation errors. 594 func (m CaveatDefinitionMultiError) AllErrors() []error { return m } 595 596 // CaveatDefinitionValidationError is the validation error returned by 597 // CaveatDefinition.Validate if the designated constraints aren't met. 598 type CaveatDefinitionValidationError struct { 599 field string 600 reason string 601 cause error 602 key bool 603 } 604 605 // Field function returns field value. 606 func (e CaveatDefinitionValidationError) Field() string { return e.field } 607 608 // Reason function returns reason value. 609 func (e CaveatDefinitionValidationError) Reason() string { return e.reason } 610 611 // Cause function returns cause value. 612 func (e CaveatDefinitionValidationError) Cause() error { return e.cause } 613 614 // Key function returns key value. 615 func (e CaveatDefinitionValidationError) Key() bool { return e.key } 616 617 // ErrorName returns error name. 618 func (e CaveatDefinitionValidationError) ErrorName() string { return "CaveatDefinitionValidationError" } 619 620 // Error satisfies the builtin error interface 621 func (e CaveatDefinitionValidationError) Error() string { 622 cause := "" 623 if e.cause != nil { 624 cause = fmt.Sprintf(" | caused by: %v", e.cause) 625 } 626 627 key := "" 628 if e.key { 629 key = "key for " 630 } 631 632 return fmt.Sprintf( 633 "invalid %sCaveatDefinition.%s: %s%s", 634 key, 635 e.field, 636 e.reason, 637 cause) 638 } 639 640 var _ error = CaveatDefinitionValidationError{} 641 642 var _ interface { 643 Field() string 644 Reason() string 645 Key() bool 646 Cause() error 647 ErrorName() string 648 } = CaveatDefinitionValidationError{} 649 650 var _CaveatDefinition_Name_Pattern = regexp.MustCompile("^(([a-zA-Z0-9_][a-zA-Z0-9/_|-]{0,127})|\\*)$") 651 652 // Validate checks the field values on CaveatTypeReference with the rules 653 // defined in the proto definition for this message. If any rules are 654 // violated, the first error encountered is returned, or nil if there are no violations. 655 func (m *CaveatTypeReference) Validate() error { 656 return m.validate(false) 657 } 658 659 // ValidateAll checks the field values on CaveatTypeReference with the rules 660 // defined in the proto definition for this message. If any rules are 661 // violated, the result is a list of violation errors wrapped in 662 // CaveatTypeReferenceMultiError, or nil if none found. 663 func (m *CaveatTypeReference) ValidateAll() error { 664 return m.validate(true) 665 } 666 667 func (m *CaveatTypeReference) validate(all bool) error { 668 if m == nil { 669 return nil 670 } 671 672 var errors []error 673 674 // no validation rules for TypeName 675 676 if len(m.GetChildTypes()) > 1 { 677 err := CaveatTypeReferenceValidationError{ 678 field: "ChildTypes", 679 reason: "value must contain no more than 1 item(s)", 680 } 681 if !all { 682 return err 683 } 684 errors = append(errors, err) 685 } 686 687 for idx, item := range m.GetChildTypes() { 688 _, _ = idx, item 689 690 if all { 691 switch v := interface{}(item).(type) { 692 case interface{ ValidateAll() error }: 693 if err := v.ValidateAll(); err != nil { 694 errors = append(errors, CaveatTypeReferenceValidationError{ 695 field: fmt.Sprintf("ChildTypes[%v]", idx), 696 reason: "embedded message failed validation", 697 cause: err, 698 }) 699 } 700 case interface{ Validate() error }: 701 if err := v.Validate(); err != nil { 702 errors = append(errors, CaveatTypeReferenceValidationError{ 703 field: fmt.Sprintf("ChildTypes[%v]", idx), 704 reason: "embedded message failed validation", 705 cause: err, 706 }) 707 } 708 } 709 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { 710 if err := v.Validate(); err != nil { 711 return CaveatTypeReferenceValidationError{ 712 field: fmt.Sprintf("ChildTypes[%v]", idx), 713 reason: "embedded message failed validation", 714 cause: err, 715 } 716 } 717 } 718 719 } 720 721 if len(errors) > 0 { 722 return CaveatTypeReferenceMultiError(errors) 723 } 724 725 return nil 726 } 727 728 // CaveatTypeReferenceMultiError is an error wrapping multiple validation 729 // errors returned by CaveatTypeReference.ValidateAll() if the designated 730 // constraints aren't met. 731 type CaveatTypeReferenceMultiError []error 732 733 // Error returns a concatenation of all the error messages it wraps. 734 func (m CaveatTypeReferenceMultiError) Error() string { 735 var msgs []string 736 for _, err := range m { 737 msgs = append(msgs, err.Error()) 738 } 739 return strings.Join(msgs, "; ") 740 } 741 742 // AllErrors returns a list of validation violation errors. 743 func (m CaveatTypeReferenceMultiError) AllErrors() []error { return m } 744 745 // CaveatTypeReferenceValidationError is the validation error returned by 746 // CaveatTypeReference.Validate if the designated constraints aren't met. 747 type CaveatTypeReferenceValidationError struct { 748 field string 749 reason string 750 cause error 751 key bool 752 } 753 754 // Field function returns field value. 755 func (e CaveatTypeReferenceValidationError) Field() string { return e.field } 756 757 // Reason function returns reason value. 758 func (e CaveatTypeReferenceValidationError) Reason() string { return e.reason } 759 760 // Cause function returns cause value. 761 func (e CaveatTypeReferenceValidationError) Cause() error { return e.cause } 762 763 // Key function returns key value. 764 func (e CaveatTypeReferenceValidationError) Key() bool { return e.key } 765 766 // ErrorName returns error name. 767 func (e CaveatTypeReferenceValidationError) ErrorName() string { 768 return "CaveatTypeReferenceValidationError" 769 } 770 771 // Error satisfies the builtin error interface 772 func (e CaveatTypeReferenceValidationError) Error() string { 773 cause := "" 774 if e.cause != nil { 775 cause = fmt.Sprintf(" | caused by: %v", e.cause) 776 } 777 778 key := "" 779 if e.key { 780 key = "key for " 781 } 782 783 return fmt.Sprintf( 784 "invalid %sCaveatTypeReference.%s: %s%s", 785 key, 786 e.field, 787 e.reason, 788 cause) 789 } 790 791 var _ error = CaveatTypeReferenceValidationError{} 792 793 var _ interface { 794 Field() string 795 Reason() string 796 Key() bool 797 Cause() error 798 ErrorName() string 799 } = CaveatTypeReferenceValidationError{} 800 801 // Validate checks the field values on ObjectAndRelation with the rules defined 802 // in the proto definition for this message. If any rules are violated, the 803 // first error encountered is returned, or nil if there are no violations. 804 func (m *ObjectAndRelation) Validate() error { 805 return m.validate(false) 806 } 807 808 // ValidateAll checks the field values on ObjectAndRelation with the rules 809 // defined in the proto definition for this message. If any rules are 810 // violated, the result is a list of violation errors wrapped in 811 // ObjectAndRelationMultiError, or nil if none found. 812 func (m *ObjectAndRelation) ValidateAll() error { 813 return m.validate(true) 814 } 815 816 func (m *ObjectAndRelation) validate(all bool) error { 817 if m == nil { 818 return nil 819 } 820 821 var errors []error 822 823 if len(m.GetNamespace()) > 128 { 824 err := ObjectAndRelationValidationError{ 825 field: "Namespace", 826 reason: "value length must be at most 128 bytes", 827 } 828 if !all { 829 return err 830 } 831 errors = append(errors, err) 832 } 833 834 if !_ObjectAndRelation_Namespace_Pattern.MatchString(m.GetNamespace()) { 835 err := ObjectAndRelationValidationError{ 836 field: "Namespace", 837 reason: "value does not match regex pattern \"^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$\"", 838 } 839 if !all { 840 return err 841 } 842 errors = append(errors, err) 843 } 844 845 if len(m.GetObjectId()) > 1024 { 846 err := ObjectAndRelationValidationError{ 847 field: "ObjectId", 848 reason: "value length must be at most 1024 bytes", 849 } 850 if !all { 851 return err 852 } 853 errors = append(errors, err) 854 } 855 856 if !_ObjectAndRelation_ObjectId_Pattern.MatchString(m.GetObjectId()) { 857 err := ObjectAndRelationValidationError{ 858 field: "ObjectId", 859 reason: "value does not match regex pattern \"^(([a-zA-Z0-9/_|\\\\-=+]{1,})|\\\\*)$\"", 860 } 861 if !all { 862 return err 863 } 864 errors = append(errors, err) 865 } 866 867 if len(m.GetRelation()) > 64 { 868 err := ObjectAndRelationValidationError{ 869 field: "Relation", 870 reason: "value length must be at most 64 bytes", 871 } 872 if !all { 873 return err 874 } 875 errors = append(errors, err) 876 } 877 878 if !_ObjectAndRelation_Relation_Pattern.MatchString(m.GetRelation()) { 879 err := ObjectAndRelationValidationError{ 880 field: "Relation", 881 reason: "value does not match regex pattern \"^(\\\\.\\\\.\\\\.|[a-z][a-z0-9_]{1,62}[a-z0-9])$\"", 882 } 883 if !all { 884 return err 885 } 886 errors = append(errors, err) 887 } 888 889 if len(errors) > 0 { 890 return ObjectAndRelationMultiError(errors) 891 } 892 893 return nil 894 } 895 896 // ObjectAndRelationMultiError is an error wrapping multiple validation errors 897 // returned by ObjectAndRelation.ValidateAll() if the designated constraints 898 // aren't met. 899 type ObjectAndRelationMultiError []error 900 901 // Error returns a concatenation of all the error messages it wraps. 902 func (m ObjectAndRelationMultiError) Error() string { 903 var msgs []string 904 for _, err := range m { 905 msgs = append(msgs, err.Error()) 906 } 907 return strings.Join(msgs, "; ") 908 } 909 910 // AllErrors returns a list of validation violation errors. 911 func (m ObjectAndRelationMultiError) AllErrors() []error { return m } 912 913 // ObjectAndRelationValidationError is the validation error returned by 914 // ObjectAndRelation.Validate if the designated constraints aren't met. 915 type ObjectAndRelationValidationError struct { 916 field string 917 reason string 918 cause error 919 key bool 920 } 921 922 // Field function returns field value. 923 func (e ObjectAndRelationValidationError) Field() string { return e.field } 924 925 // Reason function returns reason value. 926 func (e ObjectAndRelationValidationError) Reason() string { return e.reason } 927 928 // Cause function returns cause value. 929 func (e ObjectAndRelationValidationError) Cause() error { return e.cause } 930 931 // Key function returns key value. 932 func (e ObjectAndRelationValidationError) Key() bool { return e.key } 933 934 // ErrorName returns error name. 935 func (e ObjectAndRelationValidationError) ErrorName() string { 936 return "ObjectAndRelationValidationError" 937 } 938 939 // Error satisfies the builtin error interface 940 func (e ObjectAndRelationValidationError) Error() string { 941 cause := "" 942 if e.cause != nil { 943 cause = fmt.Sprintf(" | caused by: %v", e.cause) 944 } 945 946 key := "" 947 if e.key { 948 key = "key for " 949 } 950 951 return fmt.Sprintf( 952 "invalid %sObjectAndRelation.%s: %s%s", 953 key, 954 e.field, 955 e.reason, 956 cause) 957 } 958 959 var _ error = ObjectAndRelationValidationError{} 960 961 var _ interface { 962 Field() string 963 Reason() string 964 Key() bool 965 Cause() error 966 ErrorName() string 967 } = ObjectAndRelationValidationError{} 968 969 var _ObjectAndRelation_Namespace_Pattern = regexp.MustCompile("^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$") 970 971 var _ObjectAndRelation_ObjectId_Pattern = regexp.MustCompile("^(([a-zA-Z0-9/_|\\-=+]{1,})|\\*)$") 972 973 var _ObjectAndRelation_Relation_Pattern = regexp.MustCompile("^(\\.\\.\\.|[a-z][a-z0-9_]{1,62}[a-z0-9])$") 974 975 // Validate checks the field values on RelationReference with the rules defined 976 // in the proto definition for this message. If any rules are violated, the 977 // first error encountered is returned, or nil if there are no violations. 978 func (m *RelationReference) Validate() error { 979 return m.validate(false) 980 } 981 982 // ValidateAll checks the field values on RelationReference with the rules 983 // defined in the proto definition for this message. If any rules are 984 // violated, the result is a list of violation errors wrapped in 985 // RelationReferenceMultiError, or nil if none found. 986 func (m *RelationReference) ValidateAll() error { 987 return m.validate(true) 988 } 989 990 func (m *RelationReference) validate(all bool) error { 991 if m == nil { 992 return nil 993 } 994 995 var errors []error 996 997 if len(m.GetNamespace()) > 128 { 998 err := RelationReferenceValidationError{ 999 field: "Namespace", 1000 reason: "value length must be at most 128 bytes", 1001 } 1002 if !all { 1003 return err 1004 } 1005 errors = append(errors, err) 1006 } 1007 1008 if !_RelationReference_Namespace_Pattern.MatchString(m.GetNamespace()) { 1009 err := RelationReferenceValidationError{ 1010 field: "Namespace", 1011 reason: "value does not match regex pattern \"^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$\"", 1012 } 1013 if !all { 1014 return err 1015 } 1016 errors = append(errors, err) 1017 } 1018 1019 if len(m.GetRelation()) > 64 { 1020 err := RelationReferenceValidationError{ 1021 field: "Relation", 1022 reason: "value length must be at most 64 bytes", 1023 } 1024 if !all { 1025 return err 1026 } 1027 errors = append(errors, err) 1028 } 1029 1030 if !_RelationReference_Relation_Pattern.MatchString(m.GetRelation()) { 1031 err := RelationReferenceValidationError{ 1032 field: "Relation", 1033 reason: "value does not match regex pattern \"^(\\\\.\\\\.\\\\.|[a-z][a-z0-9_]{1,62}[a-z0-9])$\"", 1034 } 1035 if !all { 1036 return err 1037 } 1038 errors = append(errors, err) 1039 } 1040 1041 if len(errors) > 0 { 1042 return RelationReferenceMultiError(errors) 1043 } 1044 1045 return nil 1046 } 1047 1048 // RelationReferenceMultiError is an error wrapping multiple validation errors 1049 // returned by RelationReference.ValidateAll() if the designated constraints 1050 // aren't met. 1051 type RelationReferenceMultiError []error 1052 1053 // Error returns a concatenation of all the error messages it wraps. 1054 func (m RelationReferenceMultiError) Error() string { 1055 var msgs []string 1056 for _, err := range m { 1057 msgs = append(msgs, err.Error()) 1058 } 1059 return strings.Join(msgs, "; ") 1060 } 1061 1062 // AllErrors returns a list of validation violation errors. 1063 func (m RelationReferenceMultiError) AllErrors() []error { return m } 1064 1065 // RelationReferenceValidationError is the validation error returned by 1066 // RelationReference.Validate if the designated constraints aren't met. 1067 type RelationReferenceValidationError struct { 1068 field string 1069 reason string 1070 cause error 1071 key bool 1072 } 1073 1074 // Field function returns field value. 1075 func (e RelationReferenceValidationError) Field() string { return e.field } 1076 1077 // Reason function returns reason value. 1078 func (e RelationReferenceValidationError) Reason() string { return e.reason } 1079 1080 // Cause function returns cause value. 1081 func (e RelationReferenceValidationError) Cause() error { return e.cause } 1082 1083 // Key function returns key value. 1084 func (e RelationReferenceValidationError) Key() bool { return e.key } 1085 1086 // ErrorName returns error name. 1087 func (e RelationReferenceValidationError) ErrorName() string { 1088 return "RelationReferenceValidationError" 1089 } 1090 1091 // Error satisfies the builtin error interface 1092 func (e RelationReferenceValidationError) Error() string { 1093 cause := "" 1094 if e.cause != nil { 1095 cause = fmt.Sprintf(" | caused by: %v", e.cause) 1096 } 1097 1098 key := "" 1099 if e.key { 1100 key = "key for " 1101 } 1102 1103 return fmt.Sprintf( 1104 "invalid %sRelationReference.%s: %s%s", 1105 key, 1106 e.field, 1107 e.reason, 1108 cause) 1109 } 1110 1111 var _ error = RelationReferenceValidationError{} 1112 1113 var _ interface { 1114 Field() string 1115 Reason() string 1116 Key() bool 1117 Cause() error 1118 ErrorName() string 1119 } = RelationReferenceValidationError{} 1120 1121 var _RelationReference_Namespace_Pattern = regexp.MustCompile("^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$") 1122 1123 var _RelationReference_Relation_Pattern = regexp.MustCompile("^(\\.\\.\\.|[a-z][a-z0-9_]{1,62}[a-z0-9])$") 1124 1125 // Validate checks the field values on Zookie with the rules defined in the 1126 // proto definition for this message. If any rules are violated, the first 1127 // error encountered is returned, or nil if there are no violations. 1128 func (m *Zookie) Validate() error { 1129 return m.validate(false) 1130 } 1131 1132 // ValidateAll checks the field values on Zookie with the rules defined in the 1133 // proto definition for this message. If any rules are violated, the result is 1134 // a list of violation errors wrapped in ZookieMultiError, or nil if none found. 1135 func (m *Zookie) ValidateAll() error { 1136 return m.validate(true) 1137 } 1138 1139 func (m *Zookie) validate(all bool) error { 1140 if m == nil { 1141 return nil 1142 } 1143 1144 var errors []error 1145 1146 if len(m.GetToken()) < 1 { 1147 err := ZookieValidationError{ 1148 field: "Token", 1149 reason: "value length must be at least 1 bytes", 1150 } 1151 if !all { 1152 return err 1153 } 1154 errors = append(errors, err) 1155 } 1156 1157 if len(errors) > 0 { 1158 return ZookieMultiError(errors) 1159 } 1160 1161 return nil 1162 } 1163 1164 // ZookieMultiError is an error wrapping multiple validation errors returned by 1165 // Zookie.ValidateAll() if the designated constraints aren't met. 1166 type ZookieMultiError []error 1167 1168 // Error returns a concatenation of all the error messages it wraps. 1169 func (m ZookieMultiError) Error() string { 1170 var msgs []string 1171 for _, err := range m { 1172 msgs = append(msgs, err.Error()) 1173 } 1174 return strings.Join(msgs, "; ") 1175 } 1176 1177 // AllErrors returns a list of validation violation errors. 1178 func (m ZookieMultiError) AllErrors() []error { return m } 1179 1180 // ZookieValidationError is the validation error returned by Zookie.Validate if 1181 // the designated constraints aren't met. 1182 type ZookieValidationError struct { 1183 field string 1184 reason string 1185 cause error 1186 key bool 1187 } 1188 1189 // Field function returns field value. 1190 func (e ZookieValidationError) Field() string { return e.field } 1191 1192 // Reason function returns reason value. 1193 func (e ZookieValidationError) Reason() string { return e.reason } 1194 1195 // Cause function returns cause value. 1196 func (e ZookieValidationError) Cause() error { return e.cause } 1197 1198 // Key function returns key value. 1199 func (e ZookieValidationError) Key() bool { return e.key } 1200 1201 // ErrorName returns error name. 1202 func (e ZookieValidationError) ErrorName() string { return "ZookieValidationError" } 1203 1204 // Error satisfies the builtin error interface 1205 func (e ZookieValidationError) Error() string { 1206 cause := "" 1207 if e.cause != nil { 1208 cause = fmt.Sprintf(" | caused by: %v", e.cause) 1209 } 1210 1211 key := "" 1212 if e.key { 1213 key = "key for " 1214 } 1215 1216 return fmt.Sprintf( 1217 "invalid %sZookie.%s: %s%s", 1218 key, 1219 e.field, 1220 e.reason, 1221 cause) 1222 } 1223 1224 var _ error = ZookieValidationError{} 1225 1226 var _ interface { 1227 Field() string 1228 Reason() string 1229 Key() bool 1230 Cause() error 1231 ErrorName() string 1232 } = ZookieValidationError{} 1233 1234 // Validate checks the field values on RelationTupleUpdate with the rules 1235 // defined in the proto definition for this message. If any rules are 1236 // violated, the first error encountered is returned, or nil if there are no violations. 1237 func (m *RelationTupleUpdate) Validate() error { 1238 return m.validate(false) 1239 } 1240 1241 // ValidateAll checks the field values on RelationTupleUpdate with the rules 1242 // defined in the proto definition for this message. If any rules are 1243 // violated, the result is a list of violation errors wrapped in 1244 // RelationTupleUpdateMultiError, or nil if none found. 1245 func (m *RelationTupleUpdate) ValidateAll() error { 1246 return m.validate(true) 1247 } 1248 1249 func (m *RelationTupleUpdate) validate(all bool) error { 1250 if m == nil { 1251 return nil 1252 } 1253 1254 var errors []error 1255 1256 if _, ok := RelationTupleUpdate_Operation_name[int32(m.GetOperation())]; !ok { 1257 err := RelationTupleUpdateValidationError{ 1258 field: "Operation", 1259 reason: "value must be one of the defined enum values", 1260 } 1261 if !all { 1262 return err 1263 } 1264 errors = append(errors, err) 1265 } 1266 1267 if m.GetTuple() == nil { 1268 err := RelationTupleUpdateValidationError{ 1269 field: "Tuple", 1270 reason: "value is required", 1271 } 1272 if !all { 1273 return err 1274 } 1275 errors = append(errors, err) 1276 } 1277 1278 if all { 1279 switch v := interface{}(m.GetTuple()).(type) { 1280 case interface{ ValidateAll() error }: 1281 if err := v.ValidateAll(); err != nil { 1282 errors = append(errors, RelationTupleUpdateValidationError{ 1283 field: "Tuple", 1284 reason: "embedded message failed validation", 1285 cause: err, 1286 }) 1287 } 1288 case interface{ Validate() error }: 1289 if err := v.Validate(); err != nil { 1290 errors = append(errors, RelationTupleUpdateValidationError{ 1291 field: "Tuple", 1292 reason: "embedded message failed validation", 1293 cause: err, 1294 }) 1295 } 1296 } 1297 } else if v, ok := interface{}(m.GetTuple()).(interface{ Validate() error }); ok { 1298 if err := v.Validate(); err != nil { 1299 return RelationTupleUpdateValidationError{ 1300 field: "Tuple", 1301 reason: "embedded message failed validation", 1302 cause: err, 1303 } 1304 } 1305 } 1306 1307 if len(errors) > 0 { 1308 return RelationTupleUpdateMultiError(errors) 1309 } 1310 1311 return nil 1312 } 1313 1314 // RelationTupleUpdateMultiError is an error wrapping multiple validation 1315 // errors returned by RelationTupleUpdate.ValidateAll() if the designated 1316 // constraints aren't met. 1317 type RelationTupleUpdateMultiError []error 1318 1319 // Error returns a concatenation of all the error messages it wraps. 1320 func (m RelationTupleUpdateMultiError) Error() string { 1321 var msgs []string 1322 for _, err := range m { 1323 msgs = append(msgs, err.Error()) 1324 } 1325 return strings.Join(msgs, "; ") 1326 } 1327 1328 // AllErrors returns a list of validation violation errors. 1329 func (m RelationTupleUpdateMultiError) AllErrors() []error { return m } 1330 1331 // RelationTupleUpdateValidationError is the validation error returned by 1332 // RelationTupleUpdate.Validate if the designated constraints aren't met. 1333 type RelationTupleUpdateValidationError struct { 1334 field string 1335 reason string 1336 cause error 1337 key bool 1338 } 1339 1340 // Field function returns field value. 1341 func (e RelationTupleUpdateValidationError) Field() string { return e.field } 1342 1343 // Reason function returns reason value. 1344 func (e RelationTupleUpdateValidationError) Reason() string { return e.reason } 1345 1346 // Cause function returns cause value. 1347 func (e RelationTupleUpdateValidationError) Cause() error { return e.cause } 1348 1349 // Key function returns key value. 1350 func (e RelationTupleUpdateValidationError) Key() bool { return e.key } 1351 1352 // ErrorName returns error name. 1353 func (e RelationTupleUpdateValidationError) ErrorName() string { 1354 return "RelationTupleUpdateValidationError" 1355 } 1356 1357 // Error satisfies the builtin error interface 1358 func (e RelationTupleUpdateValidationError) Error() string { 1359 cause := "" 1360 if e.cause != nil { 1361 cause = fmt.Sprintf(" | caused by: %v", e.cause) 1362 } 1363 1364 key := "" 1365 if e.key { 1366 key = "key for " 1367 } 1368 1369 return fmt.Sprintf( 1370 "invalid %sRelationTupleUpdate.%s: %s%s", 1371 key, 1372 e.field, 1373 e.reason, 1374 cause) 1375 } 1376 1377 var _ error = RelationTupleUpdateValidationError{} 1378 1379 var _ interface { 1380 Field() string 1381 Reason() string 1382 Key() bool 1383 Cause() error 1384 ErrorName() string 1385 } = RelationTupleUpdateValidationError{} 1386 1387 // Validate checks the field values on RelationTupleTreeNode with the rules 1388 // defined in the proto definition for this message. If any rules are 1389 // violated, the first error encountered is returned, or nil if there are no violations. 1390 func (m *RelationTupleTreeNode) Validate() error { 1391 return m.validate(false) 1392 } 1393 1394 // ValidateAll checks the field values on RelationTupleTreeNode with the rules 1395 // defined in the proto definition for this message. If any rules are 1396 // violated, the result is a list of violation errors wrapped in 1397 // RelationTupleTreeNodeMultiError, or nil if none found. 1398 func (m *RelationTupleTreeNode) ValidateAll() error { 1399 return m.validate(true) 1400 } 1401 1402 func (m *RelationTupleTreeNode) validate(all bool) error { 1403 if m == nil { 1404 return nil 1405 } 1406 1407 var errors []error 1408 1409 if all { 1410 switch v := interface{}(m.GetExpanded()).(type) { 1411 case interface{ ValidateAll() error }: 1412 if err := v.ValidateAll(); err != nil { 1413 errors = append(errors, RelationTupleTreeNodeValidationError{ 1414 field: "Expanded", 1415 reason: "embedded message failed validation", 1416 cause: err, 1417 }) 1418 } 1419 case interface{ Validate() error }: 1420 if err := v.Validate(); err != nil { 1421 errors = append(errors, RelationTupleTreeNodeValidationError{ 1422 field: "Expanded", 1423 reason: "embedded message failed validation", 1424 cause: err, 1425 }) 1426 } 1427 } 1428 } else if v, ok := interface{}(m.GetExpanded()).(interface{ Validate() error }); ok { 1429 if err := v.Validate(); err != nil { 1430 return RelationTupleTreeNodeValidationError{ 1431 field: "Expanded", 1432 reason: "embedded message failed validation", 1433 cause: err, 1434 } 1435 } 1436 } 1437 1438 if all { 1439 switch v := interface{}(m.GetCaveatExpression()).(type) { 1440 case interface{ ValidateAll() error }: 1441 if err := v.ValidateAll(); err != nil { 1442 errors = append(errors, RelationTupleTreeNodeValidationError{ 1443 field: "CaveatExpression", 1444 reason: "embedded message failed validation", 1445 cause: err, 1446 }) 1447 } 1448 case interface{ Validate() error }: 1449 if err := v.Validate(); err != nil { 1450 errors = append(errors, RelationTupleTreeNodeValidationError{ 1451 field: "CaveatExpression", 1452 reason: "embedded message failed validation", 1453 cause: err, 1454 }) 1455 } 1456 } 1457 } else if v, ok := interface{}(m.GetCaveatExpression()).(interface{ Validate() error }); ok { 1458 if err := v.Validate(); err != nil { 1459 return RelationTupleTreeNodeValidationError{ 1460 field: "CaveatExpression", 1461 reason: "embedded message failed validation", 1462 cause: err, 1463 } 1464 } 1465 } 1466 1467 switch v := m.NodeType.(type) { 1468 case *RelationTupleTreeNode_IntermediateNode: 1469 if v == nil { 1470 err := RelationTupleTreeNodeValidationError{ 1471 field: "NodeType", 1472 reason: "oneof value cannot be a typed-nil", 1473 } 1474 if !all { 1475 return err 1476 } 1477 errors = append(errors, err) 1478 } 1479 1480 if all { 1481 switch v := interface{}(m.GetIntermediateNode()).(type) { 1482 case interface{ ValidateAll() error }: 1483 if err := v.ValidateAll(); err != nil { 1484 errors = append(errors, RelationTupleTreeNodeValidationError{ 1485 field: "IntermediateNode", 1486 reason: "embedded message failed validation", 1487 cause: err, 1488 }) 1489 } 1490 case interface{ Validate() error }: 1491 if err := v.Validate(); err != nil { 1492 errors = append(errors, RelationTupleTreeNodeValidationError{ 1493 field: "IntermediateNode", 1494 reason: "embedded message failed validation", 1495 cause: err, 1496 }) 1497 } 1498 } 1499 } else if v, ok := interface{}(m.GetIntermediateNode()).(interface{ Validate() error }); ok { 1500 if err := v.Validate(); err != nil { 1501 return RelationTupleTreeNodeValidationError{ 1502 field: "IntermediateNode", 1503 reason: "embedded message failed validation", 1504 cause: err, 1505 } 1506 } 1507 } 1508 1509 case *RelationTupleTreeNode_LeafNode: 1510 if v == nil { 1511 err := RelationTupleTreeNodeValidationError{ 1512 field: "NodeType", 1513 reason: "oneof value cannot be a typed-nil", 1514 } 1515 if !all { 1516 return err 1517 } 1518 errors = append(errors, err) 1519 } 1520 1521 if all { 1522 switch v := interface{}(m.GetLeafNode()).(type) { 1523 case interface{ ValidateAll() error }: 1524 if err := v.ValidateAll(); err != nil { 1525 errors = append(errors, RelationTupleTreeNodeValidationError{ 1526 field: "LeafNode", 1527 reason: "embedded message failed validation", 1528 cause: err, 1529 }) 1530 } 1531 case interface{ Validate() error }: 1532 if err := v.Validate(); err != nil { 1533 errors = append(errors, RelationTupleTreeNodeValidationError{ 1534 field: "LeafNode", 1535 reason: "embedded message failed validation", 1536 cause: err, 1537 }) 1538 } 1539 } 1540 } else if v, ok := interface{}(m.GetLeafNode()).(interface{ Validate() error }); ok { 1541 if err := v.Validate(); err != nil { 1542 return RelationTupleTreeNodeValidationError{ 1543 field: "LeafNode", 1544 reason: "embedded message failed validation", 1545 cause: err, 1546 } 1547 } 1548 } 1549 1550 default: 1551 _ = v // ensures v is used 1552 } 1553 1554 if len(errors) > 0 { 1555 return RelationTupleTreeNodeMultiError(errors) 1556 } 1557 1558 return nil 1559 } 1560 1561 // RelationTupleTreeNodeMultiError is an error wrapping multiple validation 1562 // errors returned by RelationTupleTreeNode.ValidateAll() if the designated 1563 // constraints aren't met. 1564 type RelationTupleTreeNodeMultiError []error 1565 1566 // Error returns a concatenation of all the error messages it wraps. 1567 func (m RelationTupleTreeNodeMultiError) Error() string { 1568 var msgs []string 1569 for _, err := range m { 1570 msgs = append(msgs, err.Error()) 1571 } 1572 return strings.Join(msgs, "; ") 1573 } 1574 1575 // AllErrors returns a list of validation violation errors. 1576 func (m RelationTupleTreeNodeMultiError) AllErrors() []error { return m } 1577 1578 // RelationTupleTreeNodeValidationError is the validation error returned by 1579 // RelationTupleTreeNode.Validate if the designated constraints aren't met. 1580 type RelationTupleTreeNodeValidationError struct { 1581 field string 1582 reason string 1583 cause error 1584 key bool 1585 } 1586 1587 // Field function returns field value. 1588 func (e RelationTupleTreeNodeValidationError) Field() string { return e.field } 1589 1590 // Reason function returns reason value. 1591 func (e RelationTupleTreeNodeValidationError) Reason() string { return e.reason } 1592 1593 // Cause function returns cause value. 1594 func (e RelationTupleTreeNodeValidationError) Cause() error { return e.cause } 1595 1596 // Key function returns key value. 1597 func (e RelationTupleTreeNodeValidationError) Key() bool { return e.key } 1598 1599 // ErrorName returns error name. 1600 func (e RelationTupleTreeNodeValidationError) ErrorName() string { 1601 return "RelationTupleTreeNodeValidationError" 1602 } 1603 1604 // Error satisfies the builtin error interface 1605 func (e RelationTupleTreeNodeValidationError) Error() string { 1606 cause := "" 1607 if e.cause != nil { 1608 cause = fmt.Sprintf(" | caused by: %v", e.cause) 1609 } 1610 1611 key := "" 1612 if e.key { 1613 key = "key for " 1614 } 1615 1616 return fmt.Sprintf( 1617 "invalid %sRelationTupleTreeNode.%s: %s%s", 1618 key, 1619 e.field, 1620 e.reason, 1621 cause) 1622 } 1623 1624 var _ error = RelationTupleTreeNodeValidationError{} 1625 1626 var _ interface { 1627 Field() string 1628 Reason() string 1629 Key() bool 1630 Cause() error 1631 ErrorName() string 1632 } = RelationTupleTreeNodeValidationError{} 1633 1634 // Validate checks the field values on SetOperationUserset with the rules 1635 // defined in the proto definition for this message. If any rules are 1636 // violated, the first error encountered is returned, or nil if there are no violations. 1637 func (m *SetOperationUserset) Validate() error { 1638 return m.validate(false) 1639 } 1640 1641 // ValidateAll checks the field values on SetOperationUserset with the rules 1642 // defined in the proto definition for this message. If any rules are 1643 // violated, the result is a list of violation errors wrapped in 1644 // SetOperationUsersetMultiError, or nil if none found. 1645 func (m *SetOperationUserset) ValidateAll() error { 1646 return m.validate(true) 1647 } 1648 1649 func (m *SetOperationUserset) validate(all bool) error { 1650 if m == nil { 1651 return nil 1652 } 1653 1654 var errors []error 1655 1656 // no validation rules for Operation 1657 1658 for idx, item := range m.GetChildNodes() { 1659 _, _ = idx, item 1660 1661 if all { 1662 switch v := interface{}(item).(type) { 1663 case interface{ ValidateAll() error }: 1664 if err := v.ValidateAll(); err != nil { 1665 errors = append(errors, SetOperationUsersetValidationError{ 1666 field: fmt.Sprintf("ChildNodes[%v]", idx), 1667 reason: "embedded message failed validation", 1668 cause: err, 1669 }) 1670 } 1671 case interface{ Validate() error }: 1672 if err := v.Validate(); err != nil { 1673 errors = append(errors, SetOperationUsersetValidationError{ 1674 field: fmt.Sprintf("ChildNodes[%v]", idx), 1675 reason: "embedded message failed validation", 1676 cause: err, 1677 }) 1678 } 1679 } 1680 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { 1681 if err := v.Validate(); err != nil { 1682 return SetOperationUsersetValidationError{ 1683 field: fmt.Sprintf("ChildNodes[%v]", idx), 1684 reason: "embedded message failed validation", 1685 cause: err, 1686 } 1687 } 1688 } 1689 1690 } 1691 1692 if len(errors) > 0 { 1693 return SetOperationUsersetMultiError(errors) 1694 } 1695 1696 return nil 1697 } 1698 1699 // SetOperationUsersetMultiError is an error wrapping multiple validation 1700 // errors returned by SetOperationUserset.ValidateAll() if the designated 1701 // constraints aren't met. 1702 type SetOperationUsersetMultiError []error 1703 1704 // Error returns a concatenation of all the error messages it wraps. 1705 func (m SetOperationUsersetMultiError) Error() string { 1706 var msgs []string 1707 for _, err := range m { 1708 msgs = append(msgs, err.Error()) 1709 } 1710 return strings.Join(msgs, "; ") 1711 } 1712 1713 // AllErrors returns a list of validation violation errors. 1714 func (m SetOperationUsersetMultiError) AllErrors() []error { return m } 1715 1716 // SetOperationUsersetValidationError is the validation error returned by 1717 // SetOperationUserset.Validate if the designated constraints aren't met. 1718 type SetOperationUsersetValidationError struct { 1719 field string 1720 reason string 1721 cause error 1722 key bool 1723 } 1724 1725 // Field function returns field value. 1726 func (e SetOperationUsersetValidationError) Field() string { return e.field } 1727 1728 // Reason function returns reason value. 1729 func (e SetOperationUsersetValidationError) Reason() string { return e.reason } 1730 1731 // Cause function returns cause value. 1732 func (e SetOperationUsersetValidationError) Cause() error { return e.cause } 1733 1734 // Key function returns key value. 1735 func (e SetOperationUsersetValidationError) Key() bool { return e.key } 1736 1737 // ErrorName returns error name. 1738 func (e SetOperationUsersetValidationError) ErrorName() string { 1739 return "SetOperationUsersetValidationError" 1740 } 1741 1742 // Error satisfies the builtin error interface 1743 func (e SetOperationUsersetValidationError) Error() string { 1744 cause := "" 1745 if e.cause != nil { 1746 cause = fmt.Sprintf(" | caused by: %v", e.cause) 1747 } 1748 1749 key := "" 1750 if e.key { 1751 key = "key for " 1752 } 1753 1754 return fmt.Sprintf( 1755 "invalid %sSetOperationUserset.%s: %s%s", 1756 key, 1757 e.field, 1758 e.reason, 1759 cause) 1760 } 1761 1762 var _ error = SetOperationUsersetValidationError{} 1763 1764 var _ interface { 1765 Field() string 1766 Reason() string 1767 Key() bool 1768 Cause() error 1769 ErrorName() string 1770 } = SetOperationUsersetValidationError{} 1771 1772 // Validate checks the field values on DirectSubject with the rules defined in 1773 // the proto definition for this message. If any rules are violated, the first 1774 // error encountered is returned, or nil if there are no violations. 1775 func (m *DirectSubject) Validate() error { 1776 return m.validate(false) 1777 } 1778 1779 // ValidateAll checks the field values on DirectSubject with the rules defined 1780 // in the proto definition for this message. If any rules are violated, the 1781 // result is a list of violation errors wrapped in DirectSubjectMultiError, or 1782 // nil if none found. 1783 func (m *DirectSubject) ValidateAll() error { 1784 return m.validate(true) 1785 } 1786 1787 func (m *DirectSubject) validate(all bool) error { 1788 if m == nil { 1789 return nil 1790 } 1791 1792 var errors []error 1793 1794 if all { 1795 switch v := interface{}(m.GetSubject()).(type) { 1796 case interface{ ValidateAll() error }: 1797 if err := v.ValidateAll(); err != nil { 1798 errors = append(errors, DirectSubjectValidationError{ 1799 field: "Subject", 1800 reason: "embedded message failed validation", 1801 cause: err, 1802 }) 1803 } 1804 case interface{ Validate() error }: 1805 if err := v.Validate(); err != nil { 1806 errors = append(errors, DirectSubjectValidationError{ 1807 field: "Subject", 1808 reason: "embedded message failed validation", 1809 cause: err, 1810 }) 1811 } 1812 } 1813 } else if v, ok := interface{}(m.GetSubject()).(interface{ Validate() error }); ok { 1814 if err := v.Validate(); err != nil { 1815 return DirectSubjectValidationError{ 1816 field: "Subject", 1817 reason: "embedded message failed validation", 1818 cause: err, 1819 } 1820 } 1821 } 1822 1823 if all { 1824 switch v := interface{}(m.GetCaveatExpression()).(type) { 1825 case interface{ ValidateAll() error }: 1826 if err := v.ValidateAll(); err != nil { 1827 errors = append(errors, DirectSubjectValidationError{ 1828 field: "CaveatExpression", 1829 reason: "embedded message failed validation", 1830 cause: err, 1831 }) 1832 } 1833 case interface{ Validate() error }: 1834 if err := v.Validate(); err != nil { 1835 errors = append(errors, DirectSubjectValidationError{ 1836 field: "CaveatExpression", 1837 reason: "embedded message failed validation", 1838 cause: err, 1839 }) 1840 } 1841 } 1842 } else if v, ok := interface{}(m.GetCaveatExpression()).(interface{ Validate() error }); ok { 1843 if err := v.Validate(); err != nil { 1844 return DirectSubjectValidationError{ 1845 field: "CaveatExpression", 1846 reason: "embedded message failed validation", 1847 cause: err, 1848 } 1849 } 1850 } 1851 1852 if len(errors) > 0 { 1853 return DirectSubjectMultiError(errors) 1854 } 1855 1856 return nil 1857 } 1858 1859 // DirectSubjectMultiError is an error wrapping multiple validation errors 1860 // returned by DirectSubject.ValidateAll() if the designated constraints 1861 // aren't met. 1862 type DirectSubjectMultiError []error 1863 1864 // Error returns a concatenation of all the error messages it wraps. 1865 func (m DirectSubjectMultiError) Error() string { 1866 var msgs []string 1867 for _, err := range m { 1868 msgs = append(msgs, err.Error()) 1869 } 1870 return strings.Join(msgs, "; ") 1871 } 1872 1873 // AllErrors returns a list of validation violation errors. 1874 func (m DirectSubjectMultiError) AllErrors() []error { return m } 1875 1876 // DirectSubjectValidationError is the validation error returned by 1877 // DirectSubject.Validate if the designated constraints aren't met. 1878 type DirectSubjectValidationError struct { 1879 field string 1880 reason string 1881 cause error 1882 key bool 1883 } 1884 1885 // Field function returns field value. 1886 func (e DirectSubjectValidationError) Field() string { return e.field } 1887 1888 // Reason function returns reason value. 1889 func (e DirectSubjectValidationError) Reason() string { return e.reason } 1890 1891 // Cause function returns cause value. 1892 func (e DirectSubjectValidationError) Cause() error { return e.cause } 1893 1894 // Key function returns key value. 1895 func (e DirectSubjectValidationError) Key() bool { return e.key } 1896 1897 // ErrorName returns error name. 1898 func (e DirectSubjectValidationError) ErrorName() string { return "DirectSubjectValidationError" } 1899 1900 // Error satisfies the builtin error interface 1901 func (e DirectSubjectValidationError) Error() string { 1902 cause := "" 1903 if e.cause != nil { 1904 cause = fmt.Sprintf(" | caused by: %v", e.cause) 1905 } 1906 1907 key := "" 1908 if e.key { 1909 key = "key for " 1910 } 1911 1912 return fmt.Sprintf( 1913 "invalid %sDirectSubject.%s: %s%s", 1914 key, 1915 e.field, 1916 e.reason, 1917 cause) 1918 } 1919 1920 var _ error = DirectSubjectValidationError{} 1921 1922 var _ interface { 1923 Field() string 1924 Reason() string 1925 Key() bool 1926 Cause() error 1927 ErrorName() string 1928 } = DirectSubjectValidationError{} 1929 1930 // Validate checks the field values on DirectSubjects with the rules defined in 1931 // the proto definition for this message. If any rules are violated, the first 1932 // error encountered is returned, or nil if there are no violations. 1933 func (m *DirectSubjects) Validate() error { 1934 return m.validate(false) 1935 } 1936 1937 // ValidateAll checks the field values on DirectSubjects with the rules defined 1938 // in the proto definition for this message. If any rules are violated, the 1939 // result is a list of violation errors wrapped in DirectSubjectsMultiError, 1940 // or nil if none found. 1941 func (m *DirectSubjects) ValidateAll() error { 1942 return m.validate(true) 1943 } 1944 1945 func (m *DirectSubjects) validate(all bool) error { 1946 if m == nil { 1947 return nil 1948 } 1949 1950 var errors []error 1951 1952 for idx, item := range m.GetSubjects() { 1953 _, _ = idx, item 1954 1955 if all { 1956 switch v := interface{}(item).(type) { 1957 case interface{ ValidateAll() error }: 1958 if err := v.ValidateAll(); err != nil { 1959 errors = append(errors, DirectSubjectsValidationError{ 1960 field: fmt.Sprintf("Subjects[%v]", idx), 1961 reason: "embedded message failed validation", 1962 cause: err, 1963 }) 1964 } 1965 case interface{ Validate() error }: 1966 if err := v.Validate(); err != nil { 1967 errors = append(errors, DirectSubjectsValidationError{ 1968 field: fmt.Sprintf("Subjects[%v]", idx), 1969 reason: "embedded message failed validation", 1970 cause: err, 1971 }) 1972 } 1973 } 1974 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { 1975 if err := v.Validate(); err != nil { 1976 return DirectSubjectsValidationError{ 1977 field: fmt.Sprintf("Subjects[%v]", idx), 1978 reason: "embedded message failed validation", 1979 cause: err, 1980 } 1981 } 1982 } 1983 1984 } 1985 1986 if len(errors) > 0 { 1987 return DirectSubjectsMultiError(errors) 1988 } 1989 1990 return nil 1991 } 1992 1993 // DirectSubjectsMultiError is an error wrapping multiple validation errors 1994 // returned by DirectSubjects.ValidateAll() if the designated constraints 1995 // aren't met. 1996 type DirectSubjectsMultiError []error 1997 1998 // Error returns a concatenation of all the error messages it wraps. 1999 func (m DirectSubjectsMultiError) Error() string { 2000 var msgs []string 2001 for _, err := range m { 2002 msgs = append(msgs, err.Error()) 2003 } 2004 return strings.Join(msgs, "; ") 2005 } 2006 2007 // AllErrors returns a list of validation violation errors. 2008 func (m DirectSubjectsMultiError) AllErrors() []error { return m } 2009 2010 // DirectSubjectsValidationError is the validation error returned by 2011 // DirectSubjects.Validate if the designated constraints aren't met. 2012 type DirectSubjectsValidationError struct { 2013 field string 2014 reason string 2015 cause error 2016 key bool 2017 } 2018 2019 // Field function returns field value. 2020 func (e DirectSubjectsValidationError) Field() string { return e.field } 2021 2022 // Reason function returns reason value. 2023 func (e DirectSubjectsValidationError) Reason() string { return e.reason } 2024 2025 // Cause function returns cause value. 2026 func (e DirectSubjectsValidationError) Cause() error { return e.cause } 2027 2028 // Key function returns key value. 2029 func (e DirectSubjectsValidationError) Key() bool { return e.key } 2030 2031 // ErrorName returns error name. 2032 func (e DirectSubjectsValidationError) ErrorName() string { return "DirectSubjectsValidationError" } 2033 2034 // Error satisfies the builtin error interface 2035 func (e DirectSubjectsValidationError) Error() string { 2036 cause := "" 2037 if e.cause != nil { 2038 cause = fmt.Sprintf(" | caused by: %v", e.cause) 2039 } 2040 2041 key := "" 2042 if e.key { 2043 key = "key for " 2044 } 2045 2046 return fmt.Sprintf( 2047 "invalid %sDirectSubjects.%s: %s%s", 2048 key, 2049 e.field, 2050 e.reason, 2051 cause) 2052 } 2053 2054 var _ error = DirectSubjectsValidationError{} 2055 2056 var _ interface { 2057 Field() string 2058 Reason() string 2059 Key() bool 2060 Cause() error 2061 ErrorName() string 2062 } = DirectSubjectsValidationError{} 2063 2064 // Validate checks the field values on Metadata with the rules defined in the 2065 // proto definition for this message. If any rules are violated, the first 2066 // error encountered is returned, or nil if there are no violations. 2067 func (m *Metadata) Validate() error { 2068 return m.validate(false) 2069 } 2070 2071 // ValidateAll checks the field values on Metadata with the rules defined in 2072 // the proto definition for this message. If any rules are violated, the 2073 // result is a list of violation errors wrapped in MetadataMultiError, or nil 2074 // if none found. 2075 func (m *Metadata) ValidateAll() error { 2076 return m.validate(true) 2077 } 2078 2079 func (m *Metadata) validate(all bool) error { 2080 if m == nil { 2081 return nil 2082 } 2083 2084 var errors []error 2085 2086 if len(m.GetMetadataMessage()) < 1 { 2087 err := MetadataValidationError{ 2088 field: "MetadataMessage", 2089 reason: "value must contain at least 1 item(s)", 2090 } 2091 if !all { 2092 return err 2093 } 2094 errors = append(errors, err) 2095 } 2096 2097 for idx, item := range m.GetMetadataMessage() { 2098 _, _ = idx, item 2099 2100 if item == nil { 2101 err := MetadataValidationError{ 2102 field: fmt.Sprintf("MetadataMessage[%v]", idx), 2103 reason: "value is required", 2104 } 2105 if !all { 2106 return err 2107 } 2108 errors = append(errors, err) 2109 } 2110 2111 if a := item; a != nil { 2112 2113 if _, ok := _Metadata_MetadataMessage_InLookup[a.GetTypeUrl()]; !ok { 2114 err := MetadataValidationError{ 2115 field: fmt.Sprintf("MetadataMessage[%v]", idx), 2116 reason: "type URL must be in list [type.googleapis.com/impl.v1.DocComment type.googleapis.com/impl.v1.RelationMetadata]", 2117 } 2118 if !all { 2119 return err 2120 } 2121 errors = append(errors, err) 2122 } 2123 2124 } 2125 2126 } 2127 2128 if len(errors) > 0 { 2129 return MetadataMultiError(errors) 2130 } 2131 2132 return nil 2133 } 2134 2135 // MetadataMultiError is an error wrapping multiple validation errors returned 2136 // by Metadata.ValidateAll() if the designated constraints aren't met. 2137 type MetadataMultiError []error 2138 2139 // Error returns a concatenation of all the error messages it wraps. 2140 func (m MetadataMultiError) Error() string { 2141 var msgs []string 2142 for _, err := range m { 2143 msgs = append(msgs, err.Error()) 2144 } 2145 return strings.Join(msgs, "; ") 2146 } 2147 2148 // AllErrors returns a list of validation violation errors. 2149 func (m MetadataMultiError) AllErrors() []error { return m } 2150 2151 // MetadataValidationError is the validation error returned by 2152 // Metadata.Validate if the designated constraints aren't met. 2153 type MetadataValidationError struct { 2154 field string 2155 reason string 2156 cause error 2157 key bool 2158 } 2159 2160 // Field function returns field value. 2161 func (e MetadataValidationError) Field() string { return e.field } 2162 2163 // Reason function returns reason value. 2164 func (e MetadataValidationError) Reason() string { return e.reason } 2165 2166 // Cause function returns cause value. 2167 func (e MetadataValidationError) Cause() error { return e.cause } 2168 2169 // Key function returns key value. 2170 func (e MetadataValidationError) Key() bool { return e.key } 2171 2172 // ErrorName returns error name. 2173 func (e MetadataValidationError) ErrorName() string { return "MetadataValidationError" } 2174 2175 // Error satisfies the builtin error interface 2176 func (e MetadataValidationError) Error() string { 2177 cause := "" 2178 if e.cause != nil { 2179 cause = fmt.Sprintf(" | caused by: %v", e.cause) 2180 } 2181 2182 key := "" 2183 if e.key { 2184 key = "key for " 2185 } 2186 2187 return fmt.Sprintf( 2188 "invalid %sMetadata.%s: %s%s", 2189 key, 2190 e.field, 2191 e.reason, 2192 cause) 2193 } 2194 2195 var _ error = MetadataValidationError{} 2196 2197 var _ interface { 2198 Field() string 2199 Reason() string 2200 Key() bool 2201 Cause() error 2202 ErrorName() string 2203 } = MetadataValidationError{} 2204 2205 var _Metadata_MetadataMessage_InLookup = map[string]struct{}{ 2206 "type.googleapis.com/impl.v1.DocComment": {}, 2207 "type.googleapis.com/impl.v1.RelationMetadata": {}, 2208 } 2209 2210 // Validate checks the field values on NamespaceDefinition with the rules 2211 // defined in the proto definition for this message. If any rules are 2212 // violated, the first error encountered is returned, or nil if there are no violations. 2213 func (m *NamespaceDefinition) Validate() error { 2214 return m.validate(false) 2215 } 2216 2217 // ValidateAll checks the field values on NamespaceDefinition with the rules 2218 // defined in the proto definition for this message. If any rules are 2219 // violated, the result is a list of violation errors wrapped in 2220 // NamespaceDefinitionMultiError, or nil if none found. 2221 func (m *NamespaceDefinition) ValidateAll() error { 2222 return m.validate(true) 2223 } 2224 2225 func (m *NamespaceDefinition) validate(all bool) error { 2226 if m == nil { 2227 return nil 2228 } 2229 2230 var errors []error 2231 2232 if len(m.GetName()) > 128 { 2233 err := NamespaceDefinitionValidationError{ 2234 field: "Name", 2235 reason: "value length must be at most 128 bytes", 2236 } 2237 if !all { 2238 return err 2239 } 2240 errors = append(errors, err) 2241 } 2242 2243 if !_NamespaceDefinition_Name_Pattern.MatchString(m.GetName()) { 2244 err := NamespaceDefinitionValidationError{ 2245 field: "Name", 2246 reason: "value does not match regex pattern \"^([a-z][a-z0-9_]{1,62}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$\"", 2247 } 2248 if !all { 2249 return err 2250 } 2251 errors = append(errors, err) 2252 } 2253 2254 for idx, item := range m.GetRelation() { 2255 _, _ = idx, item 2256 2257 if all { 2258 switch v := interface{}(item).(type) { 2259 case interface{ ValidateAll() error }: 2260 if err := v.ValidateAll(); err != nil { 2261 errors = append(errors, NamespaceDefinitionValidationError{ 2262 field: fmt.Sprintf("Relation[%v]", idx), 2263 reason: "embedded message failed validation", 2264 cause: err, 2265 }) 2266 } 2267 case interface{ Validate() error }: 2268 if err := v.Validate(); err != nil { 2269 errors = append(errors, NamespaceDefinitionValidationError{ 2270 field: fmt.Sprintf("Relation[%v]", idx), 2271 reason: "embedded message failed validation", 2272 cause: err, 2273 }) 2274 } 2275 } 2276 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { 2277 if err := v.Validate(); err != nil { 2278 return NamespaceDefinitionValidationError{ 2279 field: fmt.Sprintf("Relation[%v]", idx), 2280 reason: "embedded message failed validation", 2281 cause: err, 2282 } 2283 } 2284 } 2285 2286 } 2287 2288 if all { 2289 switch v := interface{}(m.GetMetadata()).(type) { 2290 case interface{ ValidateAll() error }: 2291 if err := v.ValidateAll(); err != nil { 2292 errors = append(errors, NamespaceDefinitionValidationError{ 2293 field: "Metadata", 2294 reason: "embedded message failed validation", 2295 cause: err, 2296 }) 2297 } 2298 case interface{ Validate() error }: 2299 if err := v.Validate(); err != nil { 2300 errors = append(errors, NamespaceDefinitionValidationError{ 2301 field: "Metadata", 2302 reason: "embedded message failed validation", 2303 cause: err, 2304 }) 2305 } 2306 } 2307 } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { 2308 if err := v.Validate(); err != nil { 2309 return NamespaceDefinitionValidationError{ 2310 field: "Metadata", 2311 reason: "embedded message failed validation", 2312 cause: err, 2313 } 2314 } 2315 } 2316 2317 if all { 2318 switch v := interface{}(m.GetSourcePosition()).(type) { 2319 case interface{ ValidateAll() error }: 2320 if err := v.ValidateAll(); err != nil { 2321 errors = append(errors, NamespaceDefinitionValidationError{ 2322 field: "SourcePosition", 2323 reason: "embedded message failed validation", 2324 cause: err, 2325 }) 2326 } 2327 case interface{ Validate() error }: 2328 if err := v.Validate(); err != nil { 2329 errors = append(errors, NamespaceDefinitionValidationError{ 2330 field: "SourcePosition", 2331 reason: "embedded message failed validation", 2332 cause: err, 2333 }) 2334 } 2335 } 2336 } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { 2337 if err := v.Validate(); err != nil { 2338 return NamespaceDefinitionValidationError{ 2339 field: "SourcePosition", 2340 reason: "embedded message failed validation", 2341 cause: err, 2342 } 2343 } 2344 } 2345 2346 if len(errors) > 0 { 2347 return NamespaceDefinitionMultiError(errors) 2348 } 2349 2350 return nil 2351 } 2352 2353 // NamespaceDefinitionMultiError is an error wrapping multiple validation 2354 // errors returned by NamespaceDefinition.ValidateAll() if the designated 2355 // constraints aren't met. 2356 type NamespaceDefinitionMultiError []error 2357 2358 // Error returns a concatenation of all the error messages it wraps. 2359 func (m NamespaceDefinitionMultiError) Error() string { 2360 var msgs []string 2361 for _, err := range m { 2362 msgs = append(msgs, err.Error()) 2363 } 2364 return strings.Join(msgs, "; ") 2365 } 2366 2367 // AllErrors returns a list of validation violation errors. 2368 func (m NamespaceDefinitionMultiError) AllErrors() []error { return m } 2369 2370 // NamespaceDefinitionValidationError is the validation error returned by 2371 // NamespaceDefinition.Validate if the designated constraints aren't met. 2372 type NamespaceDefinitionValidationError struct { 2373 field string 2374 reason string 2375 cause error 2376 key bool 2377 } 2378 2379 // Field function returns field value. 2380 func (e NamespaceDefinitionValidationError) Field() string { return e.field } 2381 2382 // Reason function returns reason value. 2383 func (e NamespaceDefinitionValidationError) Reason() string { return e.reason } 2384 2385 // Cause function returns cause value. 2386 func (e NamespaceDefinitionValidationError) Cause() error { return e.cause } 2387 2388 // Key function returns key value. 2389 func (e NamespaceDefinitionValidationError) Key() bool { return e.key } 2390 2391 // ErrorName returns error name. 2392 func (e NamespaceDefinitionValidationError) ErrorName() string { 2393 return "NamespaceDefinitionValidationError" 2394 } 2395 2396 // Error satisfies the builtin error interface 2397 func (e NamespaceDefinitionValidationError) Error() string { 2398 cause := "" 2399 if e.cause != nil { 2400 cause = fmt.Sprintf(" | caused by: %v", e.cause) 2401 } 2402 2403 key := "" 2404 if e.key { 2405 key = "key for " 2406 } 2407 2408 return fmt.Sprintf( 2409 "invalid %sNamespaceDefinition.%s: %s%s", 2410 key, 2411 e.field, 2412 e.reason, 2413 cause) 2414 } 2415 2416 var _ error = NamespaceDefinitionValidationError{} 2417 2418 var _ interface { 2419 Field() string 2420 Reason() string 2421 Key() bool 2422 Cause() error 2423 ErrorName() string 2424 } = NamespaceDefinitionValidationError{} 2425 2426 var _NamespaceDefinition_Name_Pattern = regexp.MustCompile("^([a-z][a-z0-9_]{1,62}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$") 2427 2428 // Validate checks the field values on Relation with the rules defined in the 2429 // proto definition for this message. If any rules are violated, the first 2430 // error encountered is returned, or nil if there are no violations. 2431 func (m *Relation) Validate() error { 2432 return m.validate(false) 2433 } 2434 2435 // ValidateAll checks the field values on Relation with the rules defined in 2436 // the proto definition for this message. If any rules are violated, the 2437 // result is a list of violation errors wrapped in RelationMultiError, or nil 2438 // if none found. 2439 func (m *Relation) ValidateAll() error { 2440 return m.validate(true) 2441 } 2442 2443 func (m *Relation) validate(all bool) error { 2444 if m == nil { 2445 return nil 2446 } 2447 2448 var errors []error 2449 2450 if len(m.GetName()) > 64 { 2451 err := RelationValidationError{ 2452 field: "Name", 2453 reason: "value length must be at most 64 bytes", 2454 } 2455 if !all { 2456 return err 2457 } 2458 errors = append(errors, err) 2459 } 2460 2461 if !_Relation_Name_Pattern.MatchString(m.GetName()) { 2462 err := RelationValidationError{ 2463 field: "Name", 2464 reason: "value does not match regex pattern \"^[a-z][a-z0-9_]{1,62}[a-z0-9]$\"", 2465 } 2466 if !all { 2467 return err 2468 } 2469 errors = append(errors, err) 2470 } 2471 2472 if all { 2473 switch v := interface{}(m.GetUsersetRewrite()).(type) { 2474 case interface{ ValidateAll() error }: 2475 if err := v.ValidateAll(); err != nil { 2476 errors = append(errors, RelationValidationError{ 2477 field: "UsersetRewrite", 2478 reason: "embedded message failed validation", 2479 cause: err, 2480 }) 2481 } 2482 case interface{ Validate() error }: 2483 if err := v.Validate(); err != nil { 2484 errors = append(errors, RelationValidationError{ 2485 field: "UsersetRewrite", 2486 reason: "embedded message failed validation", 2487 cause: err, 2488 }) 2489 } 2490 } 2491 } else if v, ok := interface{}(m.GetUsersetRewrite()).(interface{ Validate() error }); ok { 2492 if err := v.Validate(); err != nil { 2493 return RelationValidationError{ 2494 field: "UsersetRewrite", 2495 reason: "embedded message failed validation", 2496 cause: err, 2497 } 2498 } 2499 } 2500 2501 if all { 2502 switch v := interface{}(m.GetTypeInformation()).(type) { 2503 case interface{ ValidateAll() error }: 2504 if err := v.ValidateAll(); err != nil { 2505 errors = append(errors, RelationValidationError{ 2506 field: "TypeInformation", 2507 reason: "embedded message failed validation", 2508 cause: err, 2509 }) 2510 } 2511 case interface{ Validate() error }: 2512 if err := v.Validate(); err != nil { 2513 errors = append(errors, RelationValidationError{ 2514 field: "TypeInformation", 2515 reason: "embedded message failed validation", 2516 cause: err, 2517 }) 2518 } 2519 } 2520 } else if v, ok := interface{}(m.GetTypeInformation()).(interface{ Validate() error }); ok { 2521 if err := v.Validate(); err != nil { 2522 return RelationValidationError{ 2523 field: "TypeInformation", 2524 reason: "embedded message failed validation", 2525 cause: err, 2526 } 2527 } 2528 } 2529 2530 if all { 2531 switch v := interface{}(m.GetMetadata()).(type) { 2532 case interface{ ValidateAll() error }: 2533 if err := v.ValidateAll(); err != nil { 2534 errors = append(errors, RelationValidationError{ 2535 field: "Metadata", 2536 reason: "embedded message failed validation", 2537 cause: err, 2538 }) 2539 } 2540 case interface{ Validate() error }: 2541 if err := v.Validate(); err != nil { 2542 errors = append(errors, RelationValidationError{ 2543 field: "Metadata", 2544 reason: "embedded message failed validation", 2545 cause: err, 2546 }) 2547 } 2548 } 2549 } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { 2550 if err := v.Validate(); err != nil { 2551 return RelationValidationError{ 2552 field: "Metadata", 2553 reason: "embedded message failed validation", 2554 cause: err, 2555 } 2556 } 2557 } 2558 2559 if all { 2560 switch v := interface{}(m.GetSourcePosition()).(type) { 2561 case interface{ ValidateAll() error }: 2562 if err := v.ValidateAll(); err != nil { 2563 errors = append(errors, RelationValidationError{ 2564 field: "SourcePosition", 2565 reason: "embedded message failed validation", 2566 cause: err, 2567 }) 2568 } 2569 case interface{ Validate() error }: 2570 if err := v.Validate(); err != nil { 2571 errors = append(errors, RelationValidationError{ 2572 field: "SourcePosition", 2573 reason: "embedded message failed validation", 2574 cause: err, 2575 }) 2576 } 2577 } 2578 } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { 2579 if err := v.Validate(); err != nil { 2580 return RelationValidationError{ 2581 field: "SourcePosition", 2582 reason: "embedded message failed validation", 2583 cause: err, 2584 } 2585 } 2586 } 2587 2588 // no validation rules for AliasingRelation 2589 2590 // no validation rules for CanonicalCacheKey 2591 2592 if len(errors) > 0 { 2593 return RelationMultiError(errors) 2594 } 2595 2596 return nil 2597 } 2598 2599 // RelationMultiError is an error wrapping multiple validation errors returned 2600 // by Relation.ValidateAll() if the designated constraints aren't met. 2601 type RelationMultiError []error 2602 2603 // Error returns a concatenation of all the error messages it wraps. 2604 func (m RelationMultiError) Error() string { 2605 var msgs []string 2606 for _, err := range m { 2607 msgs = append(msgs, err.Error()) 2608 } 2609 return strings.Join(msgs, "; ") 2610 } 2611 2612 // AllErrors returns a list of validation violation errors. 2613 func (m RelationMultiError) AllErrors() []error { return m } 2614 2615 // RelationValidationError is the validation error returned by 2616 // Relation.Validate if the designated constraints aren't met. 2617 type RelationValidationError struct { 2618 field string 2619 reason string 2620 cause error 2621 key bool 2622 } 2623 2624 // Field function returns field value. 2625 func (e RelationValidationError) Field() string { return e.field } 2626 2627 // Reason function returns reason value. 2628 func (e RelationValidationError) Reason() string { return e.reason } 2629 2630 // Cause function returns cause value. 2631 func (e RelationValidationError) Cause() error { return e.cause } 2632 2633 // Key function returns key value. 2634 func (e RelationValidationError) Key() bool { return e.key } 2635 2636 // ErrorName returns error name. 2637 func (e RelationValidationError) ErrorName() string { return "RelationValidationError" } 2638 2639 // Error satisfies the builtin error interface 2640 func (e RelationValidationError) Error() string { 2641 cause := "" 2642 if e.cause != nil { 2643 cause = fmt.Sprintf(" | caused by: %v", e.cause) 2644 } 2645 2646 key := "" 2647 if e.key { 2648 key = "key for " 2649 } 2650 2651 return fmt.Sprintf( 2652 "invalid %sRelation.%s: %s%s", 2653 key, 2654 e.field, 2655 e.reason, 2656 cause) 2657 } 2658 2659 var _ error = RelationValidationError{} 2660 2661 var _ interface { 2662 Field() string 2663 Reason() string 2664 Key() bool 2665 Cause() error 2666 ErrorName() string 2667 } = RelationValidationError{} 2668 2669 var _Relation_Name_Pattern = regexp.MustCompile("^[a-z][a-z0-9_]{1,62}[a-z0-9]$") 2670 2671 // Validate checks the field values on ReachabilityGraph with the rules defined 2672 // in the proto definition for this message. If any rules are violated, the 2673 // first error encountered is returned, or nil if there are no violations. 2674 func (m *ReachabilityGraph) Validate() error { 2675 return m.validate(false) 2676 } 2677 2678 // ValidateAll checks the field values on ReachabilityGraph with the rules 2679 // defined in the proto definition for this message. If any rules are 2680 // violated, the result is a list of violation errors wrapped in 2681 // ReachabilityGraphMultiError, or nil if none found. 2682 func (m *ReachabilityGraph) ValidateAll() error { 2683 return m.validate(true) 2684 } 2685 2686 func (m *ReachabilityGraph) validate(all bool) error { 2687 if m == nil { 2688 return nil 2689 } 2690 2691 var errors []error 2692 2693 { 2694 sorted_keys := make([]string, len(m.GetEntrypointsBySubjectType())) 2695 i := 0 2696 for key := range m.GetEntrypointsBySubjectType() { 2697 sorted_keys[i] = key 2698 i++ 2699 } 2700 sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) 2701 for _, key := range sorted_keys { 2702 val := m.GetEntrypointsBySubjectType()[key] 2703 _ = val 2704 2705 // no validation rules for EntrypointsBySubjectType[key] 2706 2707 if all { 2708 switch v := interface{}(val).(type) { 2709 case interface{ ValidateAll() error }: 2710 if err := v.ValidateAll(); err != nil { 2711 errors = append(errors, ReachabilityGraphValidationError{ 2712 field: fmt.Sprintf("EntrypointsBySubjectType[%v]", key), 2713 reason: "embedded message failed validation", 2714 cause: err, 2715 }) 2716 } 2717 case interface{ Validate() error }: 2718 if err := v.Validate(); err != nil { 2719 errors = append(errors, ReachabilityGraphValidationError{ 2720 field: fmt.Sprintf("EntrypointsBySubjectType[%v]", key), 2721 reason: "embedded message failed validation", 2722 cause: err, 2723 }) 2724 } 2725 } 2726 } else if v, ok := interface{}(val).(interface{ Validate() error }); ok { 2727 if err := v.Validate(); err != nil { 2728 return ReachabilityGraphValidationError{ 2729 field: fmt.Sprintf("EntrypointsBySubjectType[%v]", key), 2730 reason: "embedded message failed validation", 2731 cause: err, 2732 } 2733 } 2734 } 2735 2736 } 2737 } 2738 2739 { 2740 sorted_keys := make([]string, len(m.GetEntrypointsBySubjectRelation())) 2741 i := 0 2742 for key := range m.GetEntrypointsBySubjectRelation() { 2743 sorted_keys[i] = key 2744 i++ 2745 } 2746 sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) 2747 for _, key := range sorted_keys { 2748 val := m.GetEntrypointsBySubjectRelation()[key] 2749 _ = val 2750 2751 // no validation rules for EntrypointsBySubjectRelation[key] 2752 2753 if all { 2754 switch v := interface{}(val).(type) { 2755 case interface{ ValidateAll() error }: 2756 if err := v.ValidateAll(); err != nil { 2757 errors = append(errors, ReachabilityGraphValidationError{ 2758 field: fmt.Sprintf("EntrypointsBySubjectRelation[%v]", key), 2759 reason: "embedded message failed validation", 2760 cause: err, 2761 }) 2762 } 2763 case interface{ Validate() error }: 2764 if err := v.Validate(); err != nil { 2765 errors = append(errors, ReachabilityGraphValidationError{ 2766 field: fmt.Sprintf("EntrypointsBySubjectRelation[%v]", key), 2767 reason: "embedded message failed validation", 2768 cause: err, 2769 }) 2770 } 2771 } 2772 } else if v, ok := interface{}(val).(interface{ Validate() error }); ok { 2773 if err := v.Validate(); err != nil { 2774 return ReachabilityGraphValidationError{ 2775 field: fmt.Sprintf("EntrypointsBySubjectRelation[%v]", key), 2776 reason: "embedded message failed validation", 2777 cause: err, 2778 } 2779 } 2780 } 2781 2782 } 2783 } 2784 2785 if len(errors) > 0 { 2786 return ReachabilityGraphMultiError(errors) 2787 } 2788 2789 return nil 2790 } 2791 2792 // ReachabilityGraphMultiError is an error wrapping multiple validation errors 2793 // returned by ReachabilityGraph.ValidateAll() if the designated constraints 2794 // aren't met. 2795 type ReachabilityGraphMultiError []error 2796 2797 // Error returns a concatenation of all the error messages it wraps. 2798 func (m ReachabilityGraphMultiError) Error() string { 2799 var msgs []string 2800 for _, err := range m { 2801 msgs = append(msgs, err.Error()) 2802 } 2803 return strings.Join(msgs, "; ") 2804 } 2805 2806 // AllErrors returns a list of validation violation errors. 2807 func (m ReachabilityGraphMultiError) AllErrors() []error { return m } 2808 2809 // ReachabilityGraphValidationError is the validation error returned by 2810 // ReachabilityGraph.Validate if the designated constraints aren't met. 2811 type ReachabilityGraphValidationError struct { 2812 field string 2813 reason string 2814 cause error 2815 key bool 2816 } 2817 2818 // Field function returns field value. 2819 func (e ReachabilityGraphValidationError) Field() string { return e.field } 2820 2821 // Reason function returns reason value. 2822 func (e ReachabilityGraphValidationError) Reason() string { return e.reason } 2823 2824 // Cause function returns cause value. 2825 func (e ReachabilityGraphValidationError) Cause() error { return e.cause } 2826 2827 // Key function returns key value. 2828 func (e ReachabilityGraphValidationError) Key() bool { return e.key } 2829 2830 // ErrorName returns error name. 2831 func (e ReachabilityGraphValidationError) ErrorName() string { 2832 return "ReachabilityGraphValidationError" 2833 } 2834 2835 // Error satisfies the builtin error interface 2836 func (e ReachabilityGraphValidationError) Error() string { 2837 cause := "" 2838 if e.cause != nil { 2839 cause = fmt.Sprintf(" | caused by: %v", e.cause) 2840 } 2841 2842 key := "" 2843 if e.key { 2844 key = "key for " 2845 } 2846 2847 return fmt.Sprintf( 2848 "invalid %sReachabilityGraph.%s: %s%s", 2849 key, 2850 e.field, 2851 e.reason, 2852 cause) 2853 } 2854 2855 var _ error = ReachabilityGraphValidationError{} 2856 2857 var _ interface { 2858 Field() string 2859 Reason() string 2860 Key() bool 2861 Cause() error 2862 ErrorName() string 2863 } = ReachabilityGraphValidationError{} 2864 2865 // Validate checks the field values on ReachabilityEntrypoints with the rules 2866 // defined in the proto definition for this message. If any rules are 2867 // violated, the first error encountered is returned, or nil if there are no violations. 2868 func (m *ReachabilityEntrypoints) Validate() error { 2869 return m.validate(false) 2870 } 2871 2872 // ValidateAll checks the field values on ReachabilityEntrypoints with the 2873 // rules defined in the proto definition for this message. If any rules are 2874 // violated, the result is a list of violation errors wrapped in 2875 // ReachabilityEntrypointsMultiError, or nil if none found. 2876 func (m *ReachabilityEntrypoints) ValidateAll() error { 2877 return m.validate(true) 2878 } 2879 2880 func (m *ReachabilityEntrypoints) validate(all bool) error { 2881 if m == nil { 2882 return nil 2883 } 2884 2885 var errors []error 2886 2887 for idx, item := range m.GetEntrypoints() { 2888 _, _ = idx, item 2889 2890 if all { 2891 switch v := interface{}(item).(type) { 2892 case interface{ ValidateAll() error }: 2893 if err := v.ValidateAll(); err != nil { 2894 errors = append(errors, ReachabilityEntrypointsValidationError{ 2895 field: fmt.Sprintf("Entrypoints[%v]", idx), 2896 reason: "embedded message failed validation", 2897 cause: err, 2898 }) 2899 } 2900 case interface{ Validate() error }: 2901 if err := v.Validate(); err != nil { 2902 errors = append(errors, ReachabilityEntrypointsValidationError{ 2903 field: fmt.Sprintf("Entrypoints[%v]", idx), 2904 reason: "embedded message failed validation", 2905 cause: err, 2906 }) 2907 } 2908 } 2909 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { 2910 if err := v.Validate(); err != nil { 2911 return ReachabilityEntrypointsValidationError{ 2912 field: fmt.Sprintf("Entrypoints[%v]", idx), 2913 reason: "embedded message failed validation", 2914 cause: err, 2915 } 2916 } 2917 } 2918 2919 } 2920 2921 // no validation rules for SubjectType 2922 2923 if all { 2924 switch v := interface{}(m.GetSubjectRelation()).(type) { 2925 case interface{ ValidateAll() error }: 2926 if err := v.ValidateAll(); err != nil { 2927 errors = append(errors, ReachabilityEntrypointsValidationError{ 2928 field: "SubjectRelation", 2929 reason: "embedded message failed validation", 2930 cause: err, 2931 }) 2932 } 2933 case interface{ Validate() error }: 2934 if err := v.Validate(); err != nil { 2935 errors = append(errors, ReachabilityEntrypointsValidationError{ 2936 field: "SubjectRelation", 2937 reason: "embedded message failed validation", 2938 cause: err, 2939 }) 2940 } 2941 } 2942 } else if v, ok := interface{}(m.GetSubjectRelation()).(interface{ Validate() error }); ok { 2943 if err := v.Validate(); err != nil { 2944 return ReachabilityEntrypointsValidationError{ 2945 field: "SubjectRelation", 2946 reason: "embedded message failed validation", 2947 cause: err, 2948 } 2949 } 2950 } 2951 2952 if len(errors) > 0 { 2953 return ReachabilityEntrypointsMultiError(errors) 2954 } 2955 2956 return nil 2957 } 2958 2959 // ReachabilityEntrypointsMultiError is an error wrapping multiple validation 2960 // errors returned by ReachabilityEntrypoints.ValidateAll() if the designated 2961 // constraints aren't met. 2962 type ReachabilityEntrypointsMultiError []error 2963 2964 // Error returns a concatenation of all the error messages it wraps. 2965 func (m ReachabilityEntrypointsMultiError) Error() string { 2966 var msgs []string 2967 for _, err := range m { 2968 msgs = append(msgs, err.Error()) 2969 } 2970 return strings.Join(msgs, "; ") 2971 } 2972 2973 // AllErrors returns a list of validation violation errors. 2974 func (m ReachabilityEntrypointsMultiError) AllErrors() []error { return m } 2975 2976 // ReachabilityEntrypointsValidationError is the validation error returned by 2977 // ReachabilityEntrypoints.Validate if the designated constraints aren't met. 2978 type ReachabilityEntrypointsValidationError struct { 2979 field string 2980 reason string 2981 cause error 2982 key bool 2983 } 2984 2985 // Field function returns field value. 2986 func (e ReachabilityEntrypointsValidationError) Field() string { return e.field } 2987 2988 // Reason function returns reason value. 2989 func (e ReachabilityEntrypointsValidationError) Reason() string { return e.reason } 2990 2991 // Cause function returns cause value. 2992 func (e ReachabilityEntrypointsValidationError) Cause() error { return e.cause } 2993 2994 // Key function returns key value. 2995 func (e ReachabilityEntrypointsValidationError) Key() bool { return e.key } 2996 2997 // ErrorName returns error name. 2998 func (e ReachabilityEntrypointsValidationError) ErrorName() string { 2999 return "ReachabilityEntrypointsValidationError" 3000 } 3001 3002 // Error satisfies the builtin error interface 3003 func (e ReachabilityEntrypointsValidationError) Error() string { 3004 cause := "" 3005 if e.cause != nil { 3006 cause = fmt.Sprintf(" | caused by: %v", e.cause) 3007 } 3008 3009 key := "" 3010 if e.key { 3011 key = "key for " 3012 } 3013 3014 return fmt.Sprintf( 3015 "invalid %sReachabilityEntrypoints.%s: %s%s", 3016 key, 3017 e.field, 3018 e.reason, 3019 cause) 3020 } 3021 3022 var _ error = ReachabilityEntrypointsValidationError{} 3023 3024 var _ interface { 3025 Field() string 3026 Reason() string 3027 Key() bool 3028 Cause() error 3029 ErrorName() string 3030 } = ReachabilityEntrypointsValidationError{} 3031 3032 // Validate checks the field values on ReachabilityEntrypoint with the rules 3033 // defined in the proto definition for this message. If any rules are 3034 // violated, the first error encountered is returned, or nil if there are no violations. 3035 func (m *ReachabilityEntrypoint) Validate() error { 3036 return m.validate(false) 3037 } 3038 3039 // ValidateAll checks the field values on ReachabilityEntrypoint with the rules 3040 // defined in the proto definition for this message. If any rules are 3041 // violated, the result is a list of violation errors wrapped in 3042 // ReachabilityEntrypointMultiError, or nil if none found. 3043 func (m *ReachabilityEntrypoint) ValidateAll() error { 3044 return m.validate(true) 3045 } 3046 3047 func (m *ReachabilityEntrypoint) validate(all bool) error { 3048 if m == nil { 3049 return nil 3050 } 3051 3052 var errors []error 3053 3054 // no validation rules for Kind 3055 3056 if all { 3057 switch v := interface{}(m.GetTargetRelation()).(type) { 3058 case interface{ ValidateAll() error }: 3059 if err := v.ValidateAll(); err != nil { 3060 errors = append(errors, ReachabilityEntrypointValidationError{ 3061 field: "TargetRelation", 3062 reason: "embedded message failed validation", 3063 cause: err, 3064 }) 3065 } 3066 case interface{ Validate() error }: 3067 if err := v.Validate(); err != nil { 3068 errors = append(errors, ReachabilityEntrypointValidationError{ 3069 field: "TargetRelation", 3070 reason: "embedded message failed validation", 3071 cause: err, 3072 }) 3073 } 3074 } 3075 } else if v, ok := interface{}(m.GetTargetRelation()).(interface{ Validate() error }); ok { 3076 if err := v.Validate(); err != nil { 3077 return ReachabilityEntrypointValidationError{ 3078 field: "TargetRelation", 3079 reason: "embedded message failed validation", 3080 cause: err, 3081 } 3082 } 3083 } 3084 3085 // no validation rules for ResultStatus 3086 3087 // no validation rules for TuplesetRelation 3088 3089 if len(errors) > 0 { 3090 return ReachabilityEntrypointMultiError(errors) 3091 } 3092 3093 return nil 3094 } 3095 3096 // ReachabilityEntrypointMultiError is an error wrapping multiple validation 3097 // errors returned by ReachabilityEntrypoint.ValidateAll() if the designated 3098 // constraints aren't met. 3099 type ReachabilityEntrypointMultiError []error 3100 3101 // Error returns a concatenation of all the error messages it wraps. 3102 func (m ReachabilityEntrypointMultiError) Error() string { 3103 var msgs []string 3104 for _, err := range m { 3105 msgs = append(msgs, err.Error()) 3106 } 3107 return strings.Join(msgs, "; ") 3108 } 3109 3110 // AllErrors returns a list of validation violation errors. 3111 func (m ReachabilityEntrypointMultiError) AllErrors() []error { return m } 3112 3113 // ReachabilityEntrypointValidationError is the validation error returned by 3114 // ReachabilityEntrypoint.Validate if the designated constraints aren't met. 3115 type ReachabilityEntrypointValidationError struct { 3116 field string 3117 reason string 3118 cause error 3119 key bool 3120 } 3121 3122 // Field function returns field value. 3123 func (e ReachabilityEntrypointValidationError) Field() string { return e.field } 3124 3125 // Reason function returns reason value. 3126 func (e ReachabilityEntrypointValidationError) Reason() string { return e.reason } 3127 3128 // Cause function returns cause value. 3129 func (e ReachabilityEntrypointValidationError) Cause() error { return e.cause } 3130 3131 // Key function returns key value. 3132 func (e ReachabilityEntrypointValidationError) Key() bool { return e.key } 3133 3134 // ErrorName returns error name. 3135 func (e ReachabilityEntrypointValidationError) ErrorName() string { 3136 return "ReachabilityEntrypointValidationError" 3137 } 3138 3139 // Error satisfies the builtin error interface 3140 func (e ReachabilityEntrypointValidationError) Error() string { 3141 cause := "" 3142 if e.cause != nil { 3143 cause = fmt.Sprintf(" | caused by: %v", e.cause) 3144 } 3145 3146 key := "" 3147 if e.key { 3148 key = "key for " 3149 } 3150 3151 return fmt.Sprintf( 3152 "invalid %sReachabilityEntrypoint.%s: %s%s", 3153 key, 3154 e.field, 3155 e.reason, 3156 cause) 3157 } 3158 3159 var _ error = ReachabilityEntrypointValidationError{} 3160 3161 var _ interface { 3162 Field() string 3163 Reason() string 3164 Key() bool 3165 Cause() error 3166 ErrorName() string 3167 } = ReachabilityEntrypointValidationError{} 3168 3169 // Validate checks the field values on TypeInformation with the rules defined 3170 // in the proto definition for this message. If any rules are violated, the 3171 // first error encountered is returned, or nil if there are no violations. 3172 func (m *TypeInformation) Validate() error { 3173 return m.validate(false) 3174 } 3175 3176 // ValidateAll checks the field values on TypeInformation with the rules 3177 // defined in the proto definition for this message. If any rules are 3178 // violated, the result is a list of violation errors wrapped in 3179 // TypeInformationMultiError, or nil if none found. 3180 func (m *TypeInformation) ValidateAll() error { 3181 return m.validate(true) 3182 } 3183 3184 func (m *TypeInformation) validate(all bool) error { 3185 if m == nil { 3186 return nil 3187 } 3188 3189 var errors []error 3190 3191 for idx, item := range m.GetAllowedDirectRelations() { 3192 _, _ = idx, item 3193 3194 if all { 3195 switch v := interface{}(item).(type) { 3196 case interface{ ValidateAll() error }: 3197 if err := v.ValidateAll(); err != nil { 3198 errors = append(errors, TypeInformationValidationError{ 3199 field: fmt.Sprintf("AllowedDirectRelations[%v]", idx), 3200 reason: "embedded message failed validation", 3201 cause: err, 3202 }) 3203 } 3204 case interface{ Validate() error }: 3205 if err := v.Validate(); err != nil { 3206 errors = append(errors, TypeInformationValidationError{ 3207 field: fmt.Sprintf("AllowedDirectRelations[%v]", idx), 3208 reason: "embedded message failed validation", 3209 cause: err, 3210 }) 3211 } 3212 } 3213 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { 3214 if err := v.Validate(); err != nil { 3215 return TypeInformationValidationError{ 3216 field: fmt.Sprintf("AllowedDirectRelations[%v]", idx), 3217 reason: "embedded message failed validation", 3218 cause: err, 3219 } 3220 } 3221 } 3222 3223 } 3224 3225 if len(errors) > 0 { 3226 return TypeInformationMultiError(errors) 3227 } 3228 3229 return nil 3230 } 3231 3232 // TypeInformationMultiError is an error wrapping multiple validation errors 3233 // returned by TypeInformation.ValidateAll() if the designated constraints 3234 // aren't met. 3235 type TypeInformationMultiError []error 3236 3237 // Error returns a concatenation of all the error messages it wraps. 3238 func (m TypeInformationMultiError) Error() string { 3239 var msgs []string 3240 for _, err := range m { 3241 msgs = append(msgs, err.Error()) 3242 } 3243 return strings.Join(msgs, "; ") 3244 } 3245 3246 // AllErrors returns a list of validation violation errors. 3247 func (m TypeInformationMultiError) AllErrors() []error { return m } 3248 3249 // TypeInformationValidationError is the validation error returned by 3250 // TypeInformation.Validate if the designated constraints aren't met. 3251 type TypeInformationValidationError struct { 3252 field string 3253 reason string 3254 cause error 3255 key bool 3256 } 3257 3258 // Field function returns field value. 3259 func (e TypeInformationValidationError) Field() string { return e.field } 3260 3261 // Reason function returns reason value. 3262 func (e TypeInformationValidationError) Reason() string { return e.reason } 3263 3264 // Cause function returns cause value. 3265 func (e TypeInformationValidationError) Cause() error { return e.cause } 3266 3267 // Key function returns key value. 3268 func (e TypeInformationValidationError) Key() bool { return e.key } 3269 3270 // ErrorName returns error name. 3271 func (e TypeInformationValidationError) ErrorName() string { return "TypeInformationValidationError" } 3272 3273 // Error satisfies the builtin error interface 3274 func (e TypeInformationValidationError) Error() string { 3275 cause := "" 3276 if e.cause != nil { 3277 cause = fmt.Sprintf(" | caused by: %v", e.cause) 3278 } 3279 3280 key := "" 3281 if e.key { 3282 key = "key for " 3283 } 3284 3285 return fmt.Sprintf( 3286 "invalid %sTypeInformation.%s: %s%s", 3287 key, 3288 e.field, 3289 e.reason, 3290 cause) 3291 } 3292 3293 var _ error = TypeInformationValidationError{} 3294 3295 var _ interface { 3296 Field() string 3297 Reason() string 3298 Key() bool 3299 Cause() error 3300 ErrorName() string 3301 } = TypeInformationValidationError{} 3302 3303 // Validate checks the field values on AllowedRelation with the rules defined 3304 // in the proto definition for this message. If any rules are violated, the 3305 // first error encountered is returned, or nil if there are no violations. 3306 func (m *AllowedRelation) Validate() error { 3307 return m.validate(false) 3308 } 3309 3310 // ValidateAll checks the field values on AllowedRelation with the rules 3311 // defined in the proto definition for this message. If any rules are 3312 // violated, the result is a list of violation errors wrapped in 3313 // AllowedRelationMultiError, or nil if none found. 3314 func (m *AllowedRelation) ValidateAll() error { 3315 return m.validate(true) 3316 } 3317 3318 func (m *AllowedRelation) validate(all bool) error { 3319 if m == nil { 3320 return nil 3321 } 3322 3323 var errors []error 3324 3325 if len(m.GetNamespace()) > 128 { 3326 err := AllowedRelationValidationError{ 3327 field: "Namespace", 3328 reason: "value length must be at most 128 bytes", 3329 } 3330 if !all { 3331 return err 3332 } 3333 errors = append(errors, err) 3334 } 3335 3336 if !_AllowedRelation_Namespace_Pattern.MatchString(m.GetNamespace()) { 3337 err := AllowedRelationValidationError{ 3338 field: "Namespace", 3339 reason: "value does not match regex pattern \"^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$\"", 3340 } 3341 if !all { 3342 return err 3343 } 3344 errors = append(errors, err) 3345 } 3346 3347 if all { 3348 switch v := interface{}(m.GetSourcePosition()).(type) { 3349 case interface{ ValidateAll() error }: 3350 if err := v.ValidateAll(); err != nil { 3351 errors = append(errors, AllowedRelationValidationError{ 3352 field: "SourcePosition", 3353 reason: "embedded message failed validation", 3354 cause: err, 3355 }) 3356 } 3357 case interface{ Validate() error }: 3358 if err := v.Validate(); err != nil { 3359 errors = append(errors, AllowedRelationValidationError{ 3360 field: "SourcePosition", 3361 reason: "embedded message failed validation", 3362 cause: err, 3363 }) 3364 } 3365 } 3366 } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { 3367 if err := v.Validate(); err != nil { 3368 return AllowedRelationValidationError{ 3369 field: "SourcePosition", 3370 reason: "embedded message failed validation", 3371 cause: err, 3372 } 3373 } 3374 } 3375 3376 if all { 3377 switch v := interface{}(m.GetRequiredCaveat()).(type) { 3378 case interface{ ValidateAll() error }: 3379 if err := v.ValidateAll(); err != nil { 3380 errors = append(errors, AllowedRelationValidationError{ 3381 field: "RequiredCaveat", 3382 reason: "embedded message failed validation", 3383 cause: err, 3384 }) 3385 } 3386 case interface{ Validate() error }: 3387 if err := v.Validate(); err != nil { 3388 errors = append(errors, AllowedRelationValidationError{ 3389 field: "RequiredCaveat", 3390 reason: "embedded message failed validation", 3391 cause: err, 3392 }) 3393 } 3394 } 3395 } else if v, ok := interface{}(m.GetRequiredCaveat()).(interface{ Validate() error }); ok { 3396 if err := v.Validate(); err != nil { 3397 return AllowedRelationValidationError{ 3398 field: "RequiredCaveat", 3399 reason: "embedded message failed validation", 3400 cause: err, 3401 } 3402 } 3403 } 3404 3405 switch v := m.RelationOrWildcard.(type) { 3406 case *AllowedRelation_Relation: 3407 if v == nil { 3408 err := AllowedRelationValidationError{ 3409 field: "RelationOrWildcard", 3410 reason: "oneof value cannot be a typed-nil", 3411 } 3412 if !all { 3413 return err 3414 } 3415 errors = append(errors, err) 3416 } 3417 3418 if len(m.GetRelation()) > 64 { 3419 err := AllowedRelationValidationError{ 3420 field: "Relation", 3421 reason: "value length must be at most 64 bytes", 3422 } 3423 if !all { 3424 return err 3425 } 3426 errors = append(errors, err) 3427 } 3428 3429 if !_AllowedRelation_Relation_Pattern.MatchString(m.GetRelation()) { 3430 err := AllowedRelationValidationError{ 3431 field: "Relation", 3432 reason: "value does not match regex pattern \"^(\\\\.\\\\.\\\\.|[a-z][a-z0-9_]{1,62}[a-z0-9])$\"", 3433 } 3434 if !all { 3435 return err 3436 } 3437 errors = append(errors, err) 3438 } 3439 3440 case *AllowedRelation_PublicWildcard_: 3441 if v == nil { 3442 err := AllowedRelationValidationError{ 3443 field: "RelationOrWildcard", 3444 reason: "oneof value cannot be a typed-nil", 3445 } 3446 if !all { 3447 return err 3448 } 3449 errors = append(errors, err) 3450 } 3451 3452 if all { 3453 switch v := interface{}(m.GetPublicWildcard()).(type) { 3454 case interface{ ValidateAll() error }: 3455 if err := v.ValidateAll(); err != nil { 3456 errors = append(errors, AllowedRelationValidationError{ 3457 field: "PublicWildcard", 3458 reason: "embedded message failed validation", 3459 cause: err, 3460 }) 3461 } 3462 case interface{ Validate() error }: 3463 if err := v.Validate(); err != nil { 3464 errors = append(errors, AllowedRelationValidationError{ 3465 field: "PublicWildcard", 3466 reason: "embedded message failed validation", 3467 cause: err, 3468 }) 3469 } 3470 } 3471 } else if v, ok := interface{}(m.GetPublicWildcard()).(interface{ Validate() error }); ok { 3472 if err := v.Validate(); err != nil { 3473 return AllowedRelationValidationError{ 3474 field: "PublicWildcard", 3475 reason: "embedded message failed validation", 3476 cause: err, 3477 } 3478 } 3479 } 3480 3481 default: 3482 _ = v // ensures v is used 3483 } 3484 3485 if len(errors) > 0 { 3486 return AllowedRelationMultiError(errors) 3487 } 3488 3489 return nil 3490 } 3491 3492 // AllowedRelationMultiError is an error wrapping multiple validation errors 3493 // returned by AllowedRelation.ValidateAll() if the designated constraints 3494 // aren't met. 3495 type AllowedRelationMultiError []error 3496 3497 // Error returns a concatenation of all the error messages it wraps. 3498 func (m AllowedRelationMultiError) Error() string { 3499 var msgs []string 3500 for _, err := range m { 3501 msgs = append(msgs, err.Error()) 3502 } 3503 return strings.Join(msgs, "; ") 3504 } 3505 3506 // AllErrors returns a list of validation violation errors. 3507 func (m AllowedRelationMultiError) AllErrors() []error { return m } 3508 3509 // AllowedRelationValidationError is the validation error returned by 3510 // AllowedRelation.Validate if the designated constraints aren't met. 3511 type AllowedRelationValidationError struct { 3512 field string 3513 reason string 3514 cause error 3515 key bool 3516 } 3517 3518 // Field function returns field value. 3519 func (e AllowedRelationValidationError) Field() string { return e.field } 3520 3521 // Reason function returns reason value. 3522 func (e AllowedRelationValidationError) Reason() string { return e.reason } 3523 3524 // Cause function returns cause value. 3525 func (e AllowedRelationValidationError) Cause() error { return e.cause } 3526 3527 // Key function returns key value. 3528 func (e AllowedRelationValidationError) Key() bool { return e.key } 3529 3530 // ErrorName returns error name. 3531 func (e AllowedRelationValidationError) ErrorName() string { return "AllowedRelationValidationError" } 3532 3533 // Error satisfies the builtin error interface 3534 func (e AllowedRelationValidationError) Error() string { 3535 cause := "" 3536 if e.cause != nil { 3537 cause = fmt.Sprintf(" | caused by: %v", e.cause) 3538 } 3539 3540 key := "" 3541 if e.key { 3542 key = "key for " 3543 } 3544 3545 return fmt.Sprintf( 3546 "invalid %sAllowedRelation.%s: %s%s", 3547 key, 3548 e.field, 3549 e.reason, 3550 cause) 3551 } 3552 3553 var _ error = AllowedRelationValidationError{} 3554 3555 var _ interface { 3556 Field() string 3557 Reason() string 3558 Key() bool 3559 Cause() error 3560 ErrorName() string 3561 } = AllowedRelationValidationError{} 3562 3563 var _AllowedRelation_Namespace_Pattern = regexp.MustCompile("^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$") 3564 3565 var _AllowedRelation_Relation_Pattern = regexp.MustCompile("^(\\.\\.\\.|[a-z][a-z0-9_]{1,62}[a-z0-9])$") 3566 3567 // Validate checks the field values on AllowedCaveat with the rules defined in 3568 // the proto definition for this message. If any rules are violated, the first 3569 // error encountered is returned, or nil if there are no violations. 3570 func (m *AllowedCaveat) Validate() error { 3571 return m.validate(false) 3572 } 3573 3574 // ValidateAll checks the field values on AllowedCaveat with the rules defined 3575 // in the proto definition for this message. If any rules are violated, the 3576 // result is a list of violation errors wrapped in AllowedCaveatMultiError, or 3577 // nil if none found. 3578 func (m *AllowedCaveat) ValidateAll() error { 3579 return m.validate(true) 3580 } 3581 3582 func (m *AllowedCaveat) validate(all bool) error { 3583 if m == nil { 3584 return nil 3585 } 3586 3587 var errors []error 3588 3589 // no validation rules for CaveatName 3590 3591 if len(errors) > 0 { 3592 return AllowedCaveatMultiError(errors) 3593 } 3594 3595 return nil 3596 } 3597 3598 // AllowedCaveatMultiError is an error wrapping multiple validation errors 3599 // returned by AllowedCaveat.ValidateAll() if the designated constraints 3600 // aren't met. 3601 type AllowedCaveatMultiError []error 3602 3603 // Error returns a concatenation of all the error messages it wraps. 3604 func (m AllowedCaveatMultiError) Error() string { 3605 var msgs []string 3606 for _, err := range m { 3607 msgs = append(msgs, err.Error()) 3608 } 3609 return strings.Join(msgs, "; ") 3610 } 3611 3612 // AllErrors returns a list of validation violation errors. 3613 func (m AllowedCaveatMultiError) AllErrors() []error { return m } 3614 3615 // AllowedCaveatValidationError is the validation error returned by 3616 // AllowedCaveat.Validate if the designated constraints aren't met. 3617 type AllowedCaveatValidationError struct { 3618 field string 3619 reason string 3620 cause error 3621 key bool 3622 } 3623 3624 // Field function returns field value. 3625 func (e AllowedCaveatValidationError) Field() string { return e.field } 3626 3627 // Reason function returns reason value. 3628 func (e AllowedCaveatValidationError) Reason() string { return e.reason } 3629 3630 // Cause function returns cause value. 3631 func (e AllowedCaveatValidationError) Cause() error { return e.cause } 3632 3633 // Key function returns key value. 3634 func (e AllowedCaveatValidationError) Key() bool { return e.key } 3635 3636 // ErrorName returns error name. 3637 func (e AllowedCaveatValidationError) ErrorName() string { return "AllowedCaveatValidationError" } 3638 3639 // Error satisfies the builtin error interface 3640 func (e AllowedCaveatValidationError) Error() string { 3641 cause := "" 3642 if e.cause != nil { 3643 cause = fmt.Sprintf(" | caused by: %v", e.cause) 3644 } 3645 3646 key := "" 3647 if e.key { 3648 key = "key for " 3649 } 3650 3651 return fmt.Sprintf( 3652 "invalid %sAllowedCaveat.%s: %s%s", 3653 key, 3654 e.field, 3655 e.reason, 3656 cause) 3657 } 3658 3659 var _ error = AllowedCaveatValidationError{} 3660 3661 var _ interface { 3662 Field() string 3663 Reason() string 3664 Key() bool 3665 Cause() error 3666 ErrorName() string 3667 } = AllowedCaveatValidationError{} 3668 3669 // Validate checks the field values on UsersetRewrite with the rules defined in 3670 // the proto definition for this message. If any rules are violated, the first 3671 // error encountered is returned, or nil if there are no violations. 3672 func (m *UsersetRewrite) Validate() error { 3673 return m.validate(false) 3674 } 3675 3676 // ValidateAll checks the field values on UsersetRewrite with the rules defined 3677 // in the proto definition for this message. If any rules are violated, the 3678 // result is a list of violation errors wrapped in UsersetRewriteMultiError, 3679 // or nil if none found. 3680 func (m *UsersetRewrite) ValidateAll() error { 3681 return m.validate(true) 3682 } 3683 3684 func (m *UsersetRewrite) validate(all bool) error { 3685 if m == nil { 3686 return nil 3687 } 3688 3689 var errors []error 3690 3691 if all { 3692 switch v := interface{}(m.GetSourcePosition()).(type) { 3693 case interface{ ValidateAll() error }: 3694 if err := v.ValidateAll(); err != nil { 3695 errors = append(errors, UsersetRewriteValidationError{ 3696 field: "SourcePosition", 3697 reason: "embedded message failed validation", 3698 cause: err, 3699 }) 3700 } 3701 case interface{ Validate() error }: 3702 if err := v.Validate(); err != nil { 3703 errors = append(errors, UsersetRewriteValidationError{ 3704 field: "SourcePosition", 3705 reason: "embedded message failed validation", 3706 cause: err, 3707 }) 3708 } 3709 } 3710 } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { 3711 if err := v.Validate(); err != nil { 3712 return UsersetRewriteValidationError{ 3713 field: "SourcePosition", 3714 reason: "embedded message failed validation", 3715 cause: err, 3716 } 3717 } 3718 } 3719 3720 oneofRewriteOperationPresent := false 3721 switch v := m.RewriteOperation.(type) { 3722 case *UsersetRewrite_Union: 3723 if v == nil { 3724 err := UsersetRewriteValidationError{ 3725 field: "RewriteOperation", 3726 reason: "oneof value cannot be a typed-nil", 3727 } 3728 if !all { 3729 return err 3730 } 3731 errors = append(errors, err) 3732 } 3733 oneofRewriteOperationPresent = true 3734 3735 if m.GetUnion() == nil { 3736 err := UsersetRewriteValidationError{ 3737 field: "Union", 3738 reason: "value is required", 3739 } 3740 if !all { 3741 return err 3742 } 3743 errors = append(errors, err) 3744 } 3745 3746 if all { 3747 switch v := interface{}(m.GetUnion()).(type) { 3748 case interface{ ValidateAll() error }: 3749 if err := v.ValidateAll(); err != nil { 3750 errors = append(errors, UsersetRewriteValidationError{ 3751 field: "Union", 3752 reason: "embedded message failed validation", 3753 cause: err, 3754 }) 3755 } 3756 case interface{ Validate() error }: 3757 if err := v.Validate(); err != nil { 3758 errors = append(errors, UsersetRewriteValidationError{ 3759 field: "Union", 3760 reason: "embedded message failed validation", 3761 cause: err, 3762 }) 3763 } 3764 } 3765 } else if v, ok := interface{}(m.GetUnion()).(interface{ Validate() error }); ok { 3766 if err := v.Validate(); err != nil { 3767 return UsersetRewriteValidationError{ 3768 field: "Union", 3769 reason: "embedded message failed validation", 3770 cause: err, 3771 } 3772 } 3773 } 3774 3775 case *UsersetRewrite_Intersection: 3776 if v == nil { 3777 err := UsersetRewriteValidationError{ 3778 field: "RewriteOperation", 3779 reason: "oneof value cannot be a typed-nil", 3780 } 3781 if !all { 3782 return err 3783 } 3784 errors = append(errors, err) 3785 } 3786 oneofRewriteOperationPresent = true 3787 3788 if m.GetIntersection() == nil { 3789 err := UsersetRewriteValidationError{ 3790 field: "Intersection", 3791 reason: "value is required", 3792 } 3793 if !all { 3794 return err 3795 } 3796 errors = append(errors, err) 3797 } 3798 3799 if all { 3800 switch v := interface{}(m.GetIntersection()).(type) { 3801 case interface{ ValidateAll() error }: 3802 if err := v.ValidateAll(); err != nil { 3803 errors = append(errors, UsersetRewriteValidationError{ 3804 field: "Intersection", 3805 reason: "embedded message failed validation", 3806 cause: err, 3807 }) 3808 } 3809 case interface{ Validate() error }: 3810 if err := v.Validate(); err != nil { 3811 errors = append(errors, UsersetRewriteValidationError{ 3812 field: "Intersection", 3813 reason: "embedded message failed validation", 3814 cause: err, 3815 }) 3816 } 3817 } 3818 } else if v, ok := interface{}(m.GetIntersection()).(interface{ Validate() error }); ok { 3819 if err := v.Validate(); err != nil { 3820 return UsersetRewriteValidationError{ 3821 field: "Intersection", 3822 reason: "embedded message failed validation", 3823 cause: err, 3824 } 3825 } 3826 } 3827 3828 case *UsersetRewrite_Exclusion: 3829 if v == nil { 3830 err := UsersetRewriteValidationError{ 3831 field: "RewriteOperation", 3832 reason: "oneof value cannot be a typed-nil", 3833 } 3834 if !all { 3835 return err 3836 } 3837 errors = append(errors, err) 3838 } 3839 oneofRewriteOperationPresent = true 3840 3841 if m.GetExclusion() == nil { 3842 err := UsersetRewriteValidationError{ 3843 field: "Exclusion", 3844 reason: "value is required", 3845 } 3846 if !all { 3847 return err 3848 } 3849 errors = append(errors, err) 3850 } 3851 3852 if all { 3853 switch v := interface{}(m.GetExclusion()).(type) { 3854 case interface{ ValidateAll() error }: 3855 if err := v.ValidateAll(); err != nil { 3856 errors = append(errors, UsersetRewriteValidationError{ 3857 field: "Exclusion", 3858 reason: "embedded message failed validation", 3859 cause: err, 3860 }) 3861 } 3862 case interface{ Validate() error }: 3863 if err := v.Validate(); err != nil { 3864 errors = append(errors, UsersetRewriteValidationError{ 3865 field: "Exclusion", 3866 reason: "embedded message failed validation", 3867 cause: err, 3868 }) 3869 } 3870 } 3871 } else if v, ok := interface{}(m.GetExclusion()).(interface{ Validate() error }); ok { 3872 if err := v.Validate(); err != nil { 3873 return UsersetRewriteValidationError{ 3874 field: "Exclusion", 3875 reason: "embedded message failed validation", 3876 cause: err, 3877 } 3878 } 3879 } 3880 3881 default: 3882 _ = v // ensures v is used 3883 } 3884 if !oneofRewriteOperationPresent { 3885 err := UsersetRewriteValidationError{ 3886 field: "RewriteOperation", 3887 reason: "value is required", 3888 } 3889 if !all { 3890 return err 3891 } 3892 errors = append(errors, err) 3893 } 3894 3895 if len(errors) > 0 { 3896 return UsersetRewriteMultiError(errors) 3897 } 3898 3899 return nil 3900 } 3901 3902 // UsersetRewriteMultiError is an error wrapping multiple validation errors 3903 // returned by UsersetRewrite.ValidateAll() if the designated constraints 3904 // aren't met. 3905 type UsersetRewriteMultiError []error 3906 3907 // Error returns a concatenation of all the error messages it wraps. 3908 func (m UsersetRewriteMultiError) Error() string { 3909 var msgs []string 3910 for _, err := range m { 3911 msgs = append(msgs, err.Error()) 3912 } 3913 return strings.Join(msgs, "; ") 3914 } 3915 3916 // AllErrors returns a list of validation violation errors. 3917 func (m UsersetRewriteMultiError) AllErrors() []error { return m } 3918 3919 // UsersetRewriteValidationError is the validation error returned by 3920 // UsersetRewrite.Validate if the designated constraints aren't met. 3921 type UsersetRewriteValidationError struct { 3922 field string 3923 reason string 3924 cause error 3925 key bool 3926 } 3927 3928 // Field function returns field value. 3929 func (e UsersetRewriteValidationError) Field() string { return e.field } 3930 3931 // Reason function returns reason value. 3932 func (e UsersetRewriteValidationError) Reason() string { return e.reason } 3933 3934 // Cause function returns cause value. 3935 func (e UsersetRewriteValidationError) Cause() error { return e.cause } 3936 3937 // Key function returns key value. 3938 func (e UsersetRewriteValidationError) Key() bool { return e.key } 3939 3940 // ErrorName returns error name. 3941 func (e UsersetRewriteValidationError) ErrorName() string { return "UsersetRewriteValidationError" } 3942 3943 // Error satisfies the builtin error interface 3944 func (e UsersetRewriteValidationError) Error() string { 3945 cause := "" 3946 if e.cause != nil { 3947 cause = fmt.Sprintf(" | caused by: %v", e.cause) 3948 } 3949 3950 key := "" 3951 if e.key { 3952 key = "key for " 3953 } 3954 3955 return fmt.Sprintf( 3956 "invalid %sUsersetRewrite.%s: %s%s", 3957 key, 3958 e.field, 3959 e.reason, 3960 cause) 3961 } 3962 3963 var _ error = UsersetRewriteValidationError{} 3964 3965 var _ interface { 3966 Field() string 3967 Reason() string 3968 Key() bool 3969 Cause() error 3970 ErrorName() string 3971 } = UsersetRewriteValidationError{} 3972 3973 // Validate checks the field values on SetOperation with the rules defined in 3974 // the proto definition for this message. If any rules are violated, the first 3975 // error encountered is returned, or nil if there are no violations. 3976 func (m *SetOperation) Validate() error { 3977 return m.validate(false) 3978 } 3979 3980 // ValidateAll checks the field values on SetOperation with the rules defined 3981 // in the proto definition for this message. If any rules are violated, the 3982 // result is a list of violation errors wrapped in SetOperationMultiError, or 3983 // nil if none found. 3984 func (m *SetOperation) ValidateAll() error { 3985 return m.validate(true) 3986 } 3987 3988 func (m *SetOperation) validate(all bool) error { 3989 if m == nil { 3990 return nil 3991 } 3992 3993 var errors []error 3994 3995 if len(m.GetChild()) < 1 { 3996 err := SetOperationValidationError{ 3997 field: "Child", 3998 reason: "value must contain at least 1 item(s)", 3999 } 4000 if !all { 4001 return err 4002 } 4003 errors = append(errors, err) 4004 } 4005 4006 for idx, item := range m.GetChild() { 4007 _, _ = idx, item 4008 4009 if item == nil { 4010 err := SetOperationValidationError{ 4011 field: fmt.Sprintf("Child[%v]", idx), 4012 reason: "value is required", 4013 } 4014 if !all { 4015 return err 4016 } 4017 errors = append(errors, err) 4018 } 4019 4020 if all { 4021 switch v := interface{}(item).(type) { 4022 case interface{ ValidateAll() error }: 4023 if err := v.ValidateAll(); err != nil { 4024 errors = append(errors, SetOperationValidationError{ 4025 field: fmt.Sprintf("Child[%v]", idx), 4026 reason: "embedded message failed validation", 4027 cause: err, 4028 }) 4029 } 4030 case interface{ Validate() error }: 4031 if err := v.Validate(); err != nil { 4032 errors = append(errors, SetOperationValidationError{ 4033 field: fmt.Sprintf("Child[%v]", idx), 4034 reason: "embedded message failed validation", 4035 cause: err, 4036 }) 4037 } 4038 } 4039 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { 4040 if err := v.Validate(); err != nil { 4041 return SetOperationValidationError{ 4042 field: fmt.Sprintf("Child[%v]", idx), 4043 reason: "embedded message failed validation", 4044 cause: err, 4045 } 4046 } 4047 } 4048 4049 } 4050 4051 if len(errors) > 0 { 4052 return SetOperationMultiError(errors) 4053 } 4054 4055 return nil 4056 } 4057 4058 // SetOperationMultiError is an error wrapping multiple validation errors 4059 // returned by SetOperation.ValidateAll() if the designated constraints aren't met. 4060 type SetOperationMultiError []error 4061 4062 // Error returns a concatenation of all the error messages it wraps. 4063 func (m SetOperationMultiError) Error() string { 4064 var msgs []string 4065 for _, err := range m { 4066 msgs = append(msgs, err.Error()) 4067 } 4068 return strings.Join(msgs, "; ") 4069 } 4070 4071 // AllErrors returns a list of validation violation errors. 4072 func (m SetOperationMultiError) AllErrors() []error { return m } 4073 4074 // SetOperationValidationError is the validation error returned by 4075 // SetOperation.Validate if the designated constraints aren't met. 4076 type SetOperationValidationError struct { 4077 field string 4078 reason string 4079 cause error 4080 key bool 4081 } 4082 4083 // Field function returns field value. 4084 func (e SetOperationValidationError) Field() string { return e.field } 4085 4086 // Reason function returns reason value. 4087 func (e SetOperationValidationError) Reason() string { return e.reason } 4088 4089 // Cause function returns cause value. 4090 func (e SetOperationValidationError) Cause() error { return e.cause } 4091 4092 // Key function returns key value. 4093 func (e SetOperationValidationError) Key() bool { return e.key } 4094 4095 // ErrorName returns error name. 4096 func (e SetOperationValidationError) ErrorName() string { return "SetOperationValidationError" } 4097 4098 // Error satisfies the builtin error interface 4099 func (e SetOperationValidationError) Error() string { 4100 cause := "" 4101 if e.cause != nil { 4102 cause = fmt.Sprintf(" | caused by: %v", e.cause) 4103 } 4104 4105 key := "" 4106 if e.key { 4107 key = "key for " 4108 } 4109 4110 return fmt.Sprintf( 4111 "invalid %sSetOperation.%s: %s%s", 4112 key, 4113 e.field, 4114 e.reason, 4115 cause) 4116 } 4117 4118 var _ error = SetOperationValidationError{} 4119 4120 var _ interface { 4121 Field() string 4122 Reason() string 4123 Key() bool 4124 Cause() error 4125 ErrorName() string 4126 } = SetOperationValidationError{} 4127 4128 // Validate checks the field values on TupleToUserset with the rules defined in 4129 // the proto definition for this message. If any rules are violated, the first 4130 // error encountered is returned, or nil if there are no violations. 4131 func (m *TupleToUserset) Validate() error { 4132 return m.validate(false) 4133 } 4134 4135 // ValidateAll checks the field values on TupleToUserset with the rules defined 4136 // in the proto definition for this message. If any rules are violated, the 4137 // result is a list of violation errors wrapped in TupleToUsersetMultiError, 4138 // or nil if none found. 4139 func (m *TupleToUserset) ValidateAll() error { 4140 return m.validate(true) 4141 } 4142 4143 func (m *TupleToUserset) validate(all bool) error { 4144 if m == nil { 4145 return nil 4146 } 4147 4148 var errors []error 4149 4150 if m.GetTupleset() == nil { 4151 err := TupleToUsersetValidationError{ 4152 field: "Tupleset", 4153 reason: "value is required", 4154 } 4155 if !all { 4156 return err 4157 } 4158 errors = append(errors, err) 4159 } 4160 4161 if all { 4162 switch v := interface{}(m.GetTupleset()).(type) { 4163 case interface{ ValidateAll() error }: 4164 if err := v.ValidateAll(); err != nil { 4165 errors = append(errors, TupleToUsersetValidationError{ 4166 field: "Tupleset", 4167 reason: "embedded message failed validation", 4168 cause: err, 4169 }) 4170 } 4171 case interface{ Validate() error }: 4172 if err := v.Validate(); err != nil { 4173 errors = append(errors, TupleToUsersetValidationError{ 4174 field: "Tupleset", 4175 reason: "embedded message failed validation", 4176 cause: err, 4177 }) 4178 } 4179 } 4180 } else if v, ok := interface{}(m.GetTupleset()).(interface{ Validate() error }); ok { 4181 if err := v.Validate(); err != nil { 4182 return TupleToUsersetValidationError{ 4183 field: "Tupleset", 4184 reason: "embedded message failed validation", 4185 cause: err, 4186 } 4187 } 4188 } 4189 4190 if m.GetComputedUserset() == nil { 4191 err := TupleToUsersetValidationError{ 4192 field: "ComputedUserset", 4193 reason: "value is required", 4194 } 4195 if !all { 4196 return err 4197 } 4198 errors = append(errors, err) 4199 } 4200 4201 if all { 4202 switch v := interface{}(m.GetComputedUserset()).(type) { 4203 case interface{ ValidateAll() error }: 4204 if err := v.ValidateAll(); err != nil { 4205 errors = append(errors, TupleToUsersetValidationError{ 4206 field: "ComputedUserset", 4207 reason: "embedded message failed validation", 4208 cause: err, 4209 }) 4210 } 4211 case interface{ Validate() error }: 4212 if err := v.Validate(); err != nil { 4213 errors = append(errors, TupleToUsersetValidationError{ 4214 field: "ComputedUserset", 4215 reason: "embedded message failed validation", 4216 cause: err, 4217 }) 4218 } 4219 } 4220 } else if v, ok := interface{}(m.GetComputedUserset()).(interface{ Validate() error }); ok { 4221 if err := v.Validate(); err != nil { 4222 return TupleToUsersetValidationError{ 4223 field: "ComputedUserset", 4224 reason: "embedded message failed validation", 4225 cause: err, 4226 } 4227 } 4228 } 4229 4230 if all { 4231 switch v := interface{}(m.GetSourcePosition()).(type) { 4232 case interface{ ValidateAll() error }: 4233 if err := v.ValidateAll(); err != nil { 4234 errors = append(errors, TupleToUsersetValidationError{ 4235 field: "SourcePosition", 4236 reason: "embedded message failed validation", 4237 cause: err, 4238 }) 4239 } 4240 case interface{ Validate() error }: 4241 if err := v.Validate(); err != nil { 4242 errors = append(errors, TupleToUsersetValidationError{ 4243 field: "SourcePosition", 4244 reason: "embedded message failed validation", 4245 cause: err, 4246 }) 4247 } 4248 } 4249 } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { 4250 if err := v.Validate(); err != nil { 4251 return TupleToUsersetValidationError{ 4252 field: "SourcePosition", 4253 reason: "embedded message failed validation", 4254 cause: err, 4255 } 4256 } 4257 } 4258 4259 if len(errors) > 0 { 4260 return TupleToUsersetMultiError(errors) 4261 } 4262 4263 return nil 4264 } 4265 4266 // TupleToUsersetMultiError is an error wrapping multiple validation errors 4267 // returned by TupleToUserset.ValidateAll() if the designated constraints 4268 // aren't met. 4269 type TupleToUsersetMultiError []error 4270 4271 // Error returns a concatenation of all the error messages it wraps. 4272 func (m TupleToUsersetMultiError) Error() string { 4273 var msgs []string 4274 for _, err := range m { 4275 msgs = append(msgs, err.Error()) 4276 } 4277 return strings.Join(msgs, "; ") 4278 } 4279 4280 // AllErrors returns a list of validation violation errors. 4281 func (m TupleToUsersetMultiError) AllErrors() []error { return m } 4282 4283 // TupleToUsersetValidationError is the validation error returned by 4284 // TupleToUserset.Validate if the designated constraints aren't met. 4285 type TupleToUsersetValidationError struct { 4286 field string 4287 reason string 4288 cause error 4289 key bool 4290 } 4291 4292 // Field function returns field value. 4293 func (e TupleToUsersetValidationError) Field() string { return e.field } 4294 4295 // Reason function returns reason value. 4296 func (e TupleToUsersetValidationError) Reason() string { return e.reason } 4297 4298 // Cause function returns cause value. 4299 func (e TupleToUsersetValidationError) Cause() error { return e.cause } 4300 4301 // Key function returns key value. 4302 func (e TupleToUsersetValidationError) Key() bool { return e.key } 4303 4304 // ErrorName returns error name. 4305 func (e TupleToUsersetValidationError) ErrorName() string { return "TupleToUsersetValidationError" } 4306 4307 // Error satisfies the builtin error interface 4308 func (e TupleToUsersetValidationError) Error() string { 4309 cause := "" 4310 if e.cause != nil { 4311 cause = fmt.Sprintf(" | caused by: %v", e.cause) 4312 } 4313 4314 key := "" 4315 if e.key { 4316 key = "key for " 4317 } 4318 4319 return fmt.Sprintf( 4320 "invalid %sTupleToUserset.%s: %s%s", 4321 key, 4322 e.field, 4323 e.reason, 4324 cause) 4325 } 4326 4327 var _ error = TupleToUsersetValidationError{} 4328 4329 var _ interface { 4330 Field() string 4331 Reason() string 4332 Key() bool 4333 Cause() error 4334 ErrorName() string 4335 } = TupleToUsersetValidationError{} 4336 4337 // Validate checks the field values on ComputedUserset with the rules defined 4338 // in the proto definition for this message. If any rules are violated, the 4339 // first error encountered is returned, or nil if there are no violations. 4340 func (m *ComputedUserset) Validate() error { 4341 return m.validate(false) 4342 } 4343 4344 // ValidateAll checks the field values on ComputedUserset with the rules 4345 // defined in the proto definition for this message. If any rules are 4346 // violated, the result is a list of violation errors wrapped in 4347 // ComputedUsersetMultiError, or nil if none found. 4348 func (m *ComputedUserset) ValidateAll() error { 4349 return m.validate(true) 4350 } 4351 4352 func (m *ComputedUserset) validate(all bool) error { 4353 if m == nil { 4354 return nil 4355 } 4356 4357 var errors []error 4358 4359 if _, ok := ComputedUserset_Object_name[int32(m.GetObject())]; !ok { 4360 err := ComputedUsersetValidationError{ 4361 field: "Object", 4362 reason: "value must be one of the defined enum values", 4363 } 4364 if !all { 4365 return err 4366 } 4367 errors = append(errors, err) 4368 } 4369 4370 if len(m.GetRelation()) > 64 { 4371 err := ComputedUsersetValidationError{ 4372 field: "Relation", 4373 reason: "value length must be at most 64 bytes", 4374 } 4375 if !all { 4376 return err 4377 } 4378 errors = append(errors, err) 4379 } 4380 4381 if !_ComputedUserset_Relation_Pattern.MatchString(m.GetRelation()) { 4382 err := ComputedUsersetValidationError{ 4383 field: "Relation", 4384 reason: "value does not match regex pattern \"^[a-z][a-z0-9_]{1,62}[a-z0-9]$\"", 4385 } 4386 if !all { 4387 return err 4388 } 4389 errors = append(errors, err) 4390 } 4391 4392 if all { 4393 switch v := interface{}(m.GetSourcePosition()).(type) { 4394 case interface{ ValidateAll() error }: 4395 if err := v.ValidateAll(); err != nil { 4396 errors = append(errors, ComputedUsersetValidationError{ 4397 field: "SourcePosition", 4398 reason: "embedded message failed validation", 4399 cause: err, 4400 }) 4401 } 4402 case interface{ Validate() error }: 4403 if err := v.Validate(); err != nil { 4404 errors = append(errors, ComputedUsersetValidationError{ 4405 field: "SourcePosition", 4406 reason: "embedded message failed validation", 4407 cause: err, 4408 }) 4409 } 4410 } 4411 } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { 4412 if err := v.Validate(); err != nil { 4413 return ComputedUsersetValidationError{ 4414 field: "SourcePosition", 4415 reason: "embedded message failed validation", 4416 cause: err, 4417 } 4418 } 4419 } 4420 4421 if len(errors) > 0 { 4422 return ComputedUsersetMultiError(errors) 4423 } 4424 4425 return nil 4426 } 4427 4428 // ComputedUsersetMultiError is an error wrapping multiple validation errors 4429 // returned by ComputedUserset.ValidateAll() if the designated constraints 4430 // aren't met. 4431 type ComputedUsersetMultiError []error 4432 4433 // Error returns a concatenation of all the error messages it wraps. 4434 func (m ComputedUsersetMultiError) Error() string { 4435 var msgs []string 4436 for _, err := range m { 4437 msgs = append(msgs, err.Error()) 4438 } 4439 return strings.Join(msgs, "; ") 4440 } 4441 4442 // AllErrors returns a list of validation violation errors. 4443 func (m ComputedUsersetMultiError) AllErrors() []error { return m } 4444 4445 // ComputedUsersetValidationError is the validation error returned by 4446 // ComputedUserset.Validate if the designated constraints aren't met. 4447 type ComputedUsersetValidationError struct { 4448 field string 4449 reason string 4450 cause error 4451 key bool 4452 } 4453 4454 // Field function returns field value. 4455 func (e ComputedUsersetValidationError) Field() string { return e.field } 4456 4457 // Reason function returns reason value. 4458 func (e ComputedUsersetValidationError) Reason() string { return e.reason } 4459 4460 // Cause function returns cause value. 4461 func (e ComputedUsersetValidationError) Cause() error { return e.cause } 4462 4463 // Key function returns key value. 4464 func (e ComputedUsersetValidationError) Key() bool { return e.key } 4465 4466 // ErrorName returns error name. 4467 func (e ComputedUsersetValidationError) ErrorName() string { return "ComputedUsersetValidationError" } 4468 4469 // Error satisfies the builtin error interface 4470 func (e ComputedUsersetValidationError) Error() string { 4471 cause := "" 4472 if e.cause != nil { 4473 cause = fmt.Sprintf(" | caused by: %v", e.cause) 4474 } 4475 4476 key := "" 4477 if e.key { 4478 key = "key for " 4479 } 4480 4481 return fmt.Sprintf( 4482 "invalid %sComputedUserset.%s: %s%s", 4483 key, 4484 e.field, 4485 e.reason, 4486 cause) 4487 } 4488 4489 var _ error = ComputedUsersetValidationError{} 4490 4491 var _ interface { 4492 Field() string 4493 Reason() string 4494 Key() bool 4495 Cause() error 4496 ErrorName() string 4497 } = ComputedUsersetValidationError{} 4498 4499 var _ComputedUserset_Relation_Pattern = regexp.MustCompile("^[a-z][a-z0-9_]{1,62}[a-z0-9]$") 4500 4501 // Validate checks the field values on SourcePosition with the rules defined in 4502 // the proto definition for this message. If any rules are violated, the first 4503 // error encountered is returned, or nil if there are no violations. 4504 func (m *SourcePosition) Validate() error { 4505 return m.validate(false) 4506 } 4507 4508 // ValidateAll checks the field values on SourcePosition with the rules defined 4509 // in the proto definition for this message. If any rules are violated, the 4510 // result is a list of violation errors wrapped in SourcePositionMultiError, 4511 // or nil if none found. 4512 func (m *SourcePosition) ValidateAll() error { 4513 return m.validate(true) 4514 } 4515 4516 func (m *SourcePosition) validate(all bool) error { 4517 if m == nil { 4518 return nil 4519 } 4520 4521 var errors []error 4522 4523 // no validation rules for ZeroIndexedLineNumber 4524 4525 // no validation rules for ZeroIndexedColumnPosition 4526 4527 if len(errors) > 0 { 4528 return SourcePositionMultiError(errors) 4529 } 4530 4531 return nil 4532 } 4533 4534 // SourcePositionMultiError is an error wrapping multiple validation errors 4535 // returned by SourcePosition.ValidateAll() if the designated constraints 4536 // aren't met. 4537 type SourcePositionMultiError []error 4538 4539 // Error returns a concatenation of all the error messages it wraps. 4540 func (m SourcePositionMultiError) Error() string { 4541 var msgs []string 4542 for _, err := range m { 4543 msgs = append(msgs, err.Error()) 4544 } 4545 return strings.Join(msgs, "; ") 4546 } 4547 4548 // AllErrors returns a list of validation violation errors. 4549 func (m SourcePositionMultiError) AllErrors() []error { return m } 4550 4551 // SourcePositionValidationError is the validation error returned by 4552 // SourcePosition.Validate if the designated constraints aren't met. 4553 type SourcePositionValidationError struct { 4554 field string 4555 reason string 4556 cause error 4557 key bool 4558 } 4559 4560 // Field function returns field value. 4561 func (e SourcePositionValidationError) Field() string { return e.field } 4562 4563 // Reason function returns reason value. 4564 func (e SourcePositionValidationError) Reason() string { return e.reason } 4565 4566 // Cause function returns cause value. 4567 func (e SourcePositionValidationError) Cause() error { return e.cause } 4568 4569 // Key function returns key value. 4570 func (e SourcePositionValidationError) Key() bool { return e.key } 4571 4572 // ErrorName returns error name. 4573 func (e SourcePositionValidationError) ErrorName() string { return "SourcePositionValidationError" } 4574 4575 // Error satisfies the builtin error interface 4576 func (e SourcePositionValidationError) Error() string { 4577 cause := "" 4578 if e.cause != nil { 4579 cause = fmt.Sprintf(" | caused by: %v", e.cause) 4580 } 4581 4582 key := "" 4583 if e.key { 4584 key = "key for " 4585 } 4586 4587 return fmt.Sprintf( 4588 "invalid %sSourcePosition.%s: %s%s", 4589 key, 4590 e.field, 4591 e.reason, 4592 cause) 4593 } 4594 4595 var _ error = SourcePositionValidationError{} 4596 4597 var _ interface { 4598 Field() string 4599 Reason() string 4600 Key() bool 4601 Cause() error 4602 ErrorName() string 4603 } = SourcePositionValidationError{} 4604 4605 // Validate checks the field values on CaveatExpression with the rules defined 4606 // in the proto definition for this message. If any rules are violated, the 4607 // first error encountered is returned, or nil if there are no violations. 4608 func (m *CaveatExpression) Validate() error { 4609 return m.validate(false) 4610 } 4611 4612 // ValidateAll checks the field values on CaveatExpression with the rules 4613 // defined in the proto definition for this message. If any rules are 4614 // violated, the result is a list of violation errors wrapped in 4615 // CaveatExpressionMultiError, or nil if none found. 4616 func (m *CaveatExpression) ValidateAll() error { 4617 return m.validate(true) 4618 } 4619 4620 func (m *CaveatExpression) validate(all bool) error { 4621 if m == nil { 4622 return nil 4623 } 4624 4625 var errors []error 4626 4627 switch v := m.OperationOrCaveat.(type) { 4628 case *CaveatExpression_Operation: 4629 if v == nil { 4630 err := CaveatExpressionValidationError{ 4631 field: "OperationOrCaveat", 4632 reason: "oneof value cannot be a typed-nil", 4633 } 4634 if !all { 4635 return err 4636 } 4637 errors = append(errors, err) 4638 } 4639 4640 if all { 4641 switch v := interface{}(m.GetOperation()).(type) { 4642 case interface{ ValidateAll() error }: 4643 if err := v.ValidateAll(); err != nil { 4644 errors = append(errors, CaveatExpressionValidationError{ 4645 field: "Operation", 4646 reason: "embedded message failed validation", 4647 cause: err, 4648 }) 4649 } 4650 case interface{ Validate() error }: 4651 if err := v.Validate(); err != nil { 4652 errors = append(errors, CaveatExpressionValidationError{ 4653 field: "Operation", 4654 reason: "embedded message failed validation", 4655 cause: err, 4656 }) 4657 } 4658 } 4659 } else if v, ok := interface{}(m.GetOperation()).(interface{ Validate() error }); ok { 4660 if err := v.Validate(); err != nil { 4661 return CaveatExpressionValidationError{ 4662 field: "Operation", 4663 reason: "embedded message failed validation", 4664 cause: err, 4665 } 4666 } 4667 } 4668 4669 case *CaveatExpression_Caveat: 4670 if v == nil { 4671 err := CaveatExpressionValidationError{ 4672 field: "OperationOrCaveat", 4673 reason: "oneof value cannot be a typed-nil", 4674 } 4675 if !all { 4676 return err 4677 } 4678 errors = append(errors, err) 4679 } 4680 4681 if all { 4682 switch v := interface{}(m.GetCaveat()).(type) { 4683 case interface{ ValidateAll() error }: 4684 if err := v.ValidateAll(); err != nil { 4685 errors = append(errors, CaveatExpressionValidationError{ 4686 field: "Caveat", 4687 reason: "embedded message failed validation", 4688 cause: err, 4689 }) 4690 } 4691 case interface{ Validate() error }: 4692 if err := v.Validate(); err != nil { 4693 errors = append(errors, CaveatExpressionValidationError{ 4694 field: "Caveat", 4695 reason: "embedded message failed validation", 4696 cause: err, 4697 }) 4698 } 4699 } 4700 } else if v, ok := interface{}(m.GetCaveat()).(interface{ Validate() error }); ok { 4701 if err := v.Validate(); err != nil { 4702 return CaveatExpressionValidationError{ 4703 field: "Caveat", 4704 reason: "embedded message failed validation", 4705 cause: err, 4706 } 4707 } 4708 } 4709 4710 default: 4711 _ = v // ensures v is used 4712 } 4713 4714 if len(errors) > 0 { 4715 return CaveatExpressionMultiError(errors) 4716 } 4717 4718 return nil 4719 } 4720 4721 // CaveatExpressionMultiError is an error wrapping multiple validation errors 4722 // returned by CaveatExpression.ValidateAll() if the designated constraints 4723 // aren't met. 4724 type CaveatExpressionMultiError []error 4725 4726 // Error returns a concatenation of all the error messages it wraps. 4727 func (m CaveatExpressionMultiError) Error() string { 4728 var msgs []string 4729 for _, err := range m { 4730 msgs = append(msgs, err.Error()) 4731 } 4732 return strings.Join(msgs, "; ") 4733 } 4734 4735 // AllErrors returns a list of validation violation errors. 4736 func (m CaveatExpressionMultiError) AllErrors() []error { return m } 4737 4738 // CaveatExpressionValidationError is the validation error returned by 4739 // CaveatExpression.Validate if the designated constraints aren't met. 4740 type CaveatExpressionValidationError struct { 4741 field string 4742 reason string 4743 cause error 4744 key bool 4745 } 4746 4747 // Field function returns field value. 4748 func (e CaveatExpressionValidationError) Field() string { return e.field } 4749 4750 // Reason function returns reason value. 4751 func (e CaveatExpressionValidationError) Reason() string { return e.reason } 4752 4753 // Cause function returns cause value. 4754 func (e CaveatExpressionValidationError) Cause() error { return e.cause } 4755 4756 // Key function returns key value. 4757 func (e CaveatExpressionValidationError) Key() bool { return e.key } 4758 4759 // ErrorName returns error name. 4760 func (e CaveatExpressionValidationError) ErrorName() string { return "CaveatExpressionValidationError" } 4761 4762 // Error satisfies the builtin error interface 4763 func (e CaveatExpressionValidationError) Error() string { 4764 cause := "" 4765 if e.cause != nil { 4766 cause = fmt.Sprintf(" | caused by: %v", e.cause) 4767 } 4768 4769 key := "" 4770 if e.key { 4771 key = "key for " 4772 } 4773 4774 return fmt.Sprintf( 4775 "invalid %sCaveatExpression.%s: %s%s", 4776 key, 4777 e.field, 4778 e.reason, 4779 cause) 4780 } 4781 4782 var _ error = CaveatExpressionValidationError{} 4783 4784 var _ interface { 4785 Field() string 4786 Reason() string 4787 Key() bool 4788 Cause() error 4789 ErrorName() string 4790 } = CaveatExpressionValidationError{} 4791 4792 // Validate checks the field values on CaveatOperation with the rules defined 4793 // in the proto definition for this message. If any rules are violated, the 4794 // first error encountered is returned, or nil if there are no violations. 4795 func (m *CaveatOperation) Validate() error { 4796 return m.validate(false) 4797 } 4798 4799 // ValidateAll checks the field values on CaveatOperation with the rules 4800 // defined in the proto definition for this message. If any rules are 4801 // violated, the result is a list of violation errors wrapped in 4802 // CaveatOperationMultiError, or nil if none found. 4803 func (m *CaveatOperation) ValidateAll() error { 4804 return m.validate(true) 4805 } 4806 4807 func (m *CaveatOperation) validate(all bool) error { 4808 if m == nil { 4809 return nil 4810 } 4811 4812 var errors []error 4813 4814 // no validation rules for Op 4815 4816 for idx, item := range m.GetChildren() { 4817 _, _ = idx, item 4818 4819 if all { 4820 switch v := interface{}(item).(type) { 4821 case interface{ ValidateAll() error }: 4822 if err := v.ValidateAll(); err != nil { 4823 errors = append(errors, CaveatOperationValidationError{ 4824 field: fmt.Sprintf("Children[%v]", idx), 4825 reason: "embedded message failed validation", 4826 cause: err, 4827 }) 4828 } 4829 case interface{ Validate() error }: 4830 if err := v.Validate(); err != nil { 4831 errors = append(errors, CaveatOperationValidationError{ 4832 field: fmt.Sprintf("Children[%v]", idx), 4833 reason: "embedded message failed validation", 4834 cause: err, 4835 }) 4836 } 4837 } 4838 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { 4839 if err := v.Validate(); err != nil { 4840 return CaveatOperationValidationError{ 4841 field: fmt.Sprintf("Children[%v]", idx), 4842 reason: "embedded message failed validation", 4843 cause: err, 4844 } 4845 } 4846 } 4847 4848 } 4849 4850 if len(errors) > 0 { 4851 return CaveatOperationMultiError(errors) 4852 } 4853 4854 return nil 4855 } 4856 4857 // CaveatOperationMultiError is an error wrapping multiple validation errors 4858 // returned by CaveatOperation.ValidateAll() if the designated constraints 4859 // aren't met. 4860 type CaveatOperationMultiError []error 4861 4862 // Error returns a concatenation of all the error messages it wraps. 4863 func (m CaveatOperationMultiError) Error() string { 4864 var msgs []string 4865 for _, err := range m { 4866 msgs = append(msgs, err.Error()) 4867 } 4868 return strings.Join(msgs, "; ") 4869 } 4870 4871 // AllErrors returns a list of validation violation errors. 4872 func (m CaveatOperationMultiError) AllErrors() []error { return m } 4873 4874 // CaveatOperationValidationError is the validation error returned by 4875 // CaveatOperation.Validate if the designated constraints aren't met. 4876 type CaveatOperationValidationError struct { 4877 field string 4878 reason string 4879 cause error 4880 key bool 4881 } 4882 4883 // Field function returns field value. 4884 func (e CaveatOperationValidationError) Field() string { return e.field } 4885 4886 // Reason function returns reason value. 4887 func (e CaveatOperationValidationError) Reason() string { return e.reason } 4888 4889 // Cause function returns cause value. 4890 func (e CaveatOperationValidationError) Cause() error { return e.cause } 4891 4892 // Key function returns key value. 4893 func (e CaveatOperationValidationError) Key() bool { return e.key } 4894 4895 // ErrorName returns error name. 4896 func (e CaveatOperationValidationError) ErrorName() string { return "CaveatOperationValidationError" } 4897 4898 // Error satisfies the builtin error interface 4899 func (e CaveatOperationValidationError) Error() string { 4900 cause := "" 4901 if e.cause != nil { 4902 cause = fmt.Sprintf(" | caused by: %v", e.cause) 4903 } 4904 4905 key := "" 4906 if e.key { 4907 key = "key for " 4908 } 4909 4910 return fmt.Sprintf( 4911 "invalid %sCaveatOperation.%s: %s%s", 4912 key, 4913 e.field, 4914 e.reason, 4915 cause) 4916 } 4917 4918 var _ error = CaveatOperationValidationError{} 4919 4920 var _ interface { 4921 Field() string 4922 Reason() string 4923 Key() bool 4924 Cause() error 4925 ErrorName() string 4926 } = CaveatOperationValidationError{} 4927 4928 // Validate checks the field values on AllowedRelation_PublicWildcard with the 4929 // rules defined in the proto definition for this message. If any rules are 4930 // violated, the first error encountered is returned, or nil if there are no violations. 4931 func (m *AllowedRelation_PublicWildcard) Validate() error { 4932 return m.validate(false) 4933 } 4934 4935 // ValidateAll checks the field values on AllowedRelation_PublicWildcard with 4936 // the rules defined in the proto definition for this message. If any rules 4937 // are violated, the result is a list of violation errors wrapped in 4938 // AllowedRelation_PublicWildcardMultiError, or nil if none found. 4939 func (m *AllowedRelation_PublicWildcard) ValidateAll() error { 4940 return m.validate(true) 4941 } 4942 4943 func (m *AllowedRelation_PublicWildcard) validate(all bool) error { 4944 if m == nil { 4945 return nil 4946 } 4947 4948 var errors []error 4949 4950 if len(errors) > 0 { 4951 return AllowedRelation_PublicWildcardMultiError(errors) 4952 } 4953 4954 return nil 4955 } 4956 4957 // AllowedRelation_PublicWildcardMultiError is an error wrapping multiple 4958 // validation errors returned by AllowedRelation_PublicWildcard.ValidateAll() 4959 // if the designated constraints aren't met. 4960 type AllowedRelation_PublicWildcardMultiError []error 4961 4962 // Error returns a concatenation of all the error messages it wraps. 4963 func (m AllowedRelation_PublicWildcardMultiError) Error() string { 4964 var msgs []string 4965 for _, err := range m { 4966 msgs = append(msgs, err.Error()) 4967 } 4968 return strings.Join(msgs, "; ") 4969 } 4970 4971 // AllErrors returns a list of validation violation errors. 4972 func (m AllowedRelation_PublicWildcardMultiError) AllErrors() []error { return m } 4973 4974 // AllowedRelation_PublicWildcardValidationError is the validation error 4975 // returned by AllowedRelation_PublicWildcard.Validate if the designated 4976 // constraints aren't met. 4977 type AllowedRelation_PublicWildcardValidationError struct { 4978 field string 4979 reason string 4980 cause error 4981 key bool 4982 } 4983 4984 // Field function returns field value. 4985 func (e AllowedRelation_PublicWildcardValidationError) Field() string { return e.field } 4986 4987 // Reason function returns reason value. 4988 func (e AllowedRelation_PublicWildcardValidationError) Reason() string { return e.reason } 4989 4990 // Cause function returns cause value. 4991 func (e AllowedRelation_PublicWildcardValidationError) Cause() error { return e.cause } 4992 4993 // Key function returns key value. 4994 func (e AllowedRelation_PublicWildcardValidationError) Key() bool { return e.key } 4995 4996 // ErrorName returns error name. 4997 func (e AllowedRelation_PublicWildcardValidationError) ErrorName() string { 4998 return "AllowedRelation_PublicWildcardValidationError" 4999 } 5000 5001 // Error satisfies the builtin error interface 5002 func (e AllowedRelation_PublicWildcardValidationError) Error() string { 5003 cause := "" 5004 if e.cause != nil { 5005 cause = fmt.Sprintf(" | caused by: %v", e.cause) 5006 } 5007 5008 key := "" 5009 if e.key { 5010 key = "key for " 5011 } 5012 5013 return fmt.Sprintf( 5014 "invalid %sAllowedRelation_PublicWildcard.%s: %s%s", 5015 key, 5016 e.field, 5017 e.reason, 5018 cause) 5019 } 5020 5021 var _ error = AllowedRelation_PublicWildcardValidationError{} 5022 5023 var _ interface { 5024 Field() string 5025 Reason() string 5026 Key() bool 5027 Cause() error 5028 ErrorName() string 5029 } = AllowedRelation_PublicWildcardValidationError{} 5030 5031 // Validate checks the field values on SetOperation_Child with the rules 5032 // defined in the proto definition for this message. If any rules are 5033 // violated, the first error encountered is returned, or nil if there are no violations. 5034 func (m *SetOperation_Child) Validate() error { 5035 return m.validate(false) 5036 } 5037 5038 // ValidateAll checks the field values on SetOperation_Child with the rules 5039 // defined in the proto definition for this message. If any rules are 5040 // violated, the result is a list of violation errors wrapped in 5041 // SetOperation_ChildMultiError, or nil if none found. 5042 func (m *SetOperation_Child) ValidateAll() error { 5043 return m.validate(true) 5044 } 5045 5046 func (m *SetOperation_Child) validate(all bool) error { 5047 if m == nil { 5048 return nil 5049 } 5050 5051 var errors []error 5052 5053 if all { 5054 switch v := interface{}(m.GetSourcePosition()).(type) { 5055 case interface{ ValidateAll() error }: 5056 if err := v.ValidateAll(); err != nil { 5057 errors = append(errors, SetOperation_ChildValidationError{ 5058 field: "SourcePosition", 5059 reason: "embedded message failed validation", 5060 cause: err, 5061 }) 5062 } 5063 case interface{ Validate() error }: 5064 if err := v.Validate(); err != nil { 5065 errors = append(errors, SetOperation_ChildValidationError{ 5066 field: "SourcePosition", 5067 reason: "embedded message failed validation", 5068 cause: err, 5069 }) 5070 } 5071 } 5072 } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { 5073 if err := v.Validate(); err != nil { 5074 return SetOperation_ChildValidationError{ 5075 field: "SourcePosition", 5076 reason: "embedded message failed validation", 5077 cause: err, 5078 } 5079 } 5080 } 5081 5082 oneofChildTypePresent := false 5083 switch v := m.ChildType.(type) { 5084 case *SetOperation_Child_XThis: 5085 if v == nil { 5086 err := SetOperation_ChildValidationError{ 5087 field: "ChildType", 5088 reason: "oneof value cannot be a typed-nil", 5089 } 5090 if !all { 5091 return err 5092 } 5093 errors = append(errors, err) 5094 } 5095 oneofChildTypePresent = true 5096 5097 if all { 5098 switch v := interface{}(m.GetXThis()).(type) { 5099 case interface{ ValidateAll() error }: 5100 if err := v.ValidateAll(); err != nil { 5101 errors = append(errors, SetOperation_ChildValidationError{ 5102 field: "XThis", 5103 reason: "embedded message failed validation", 5104 cause: err, 5105 }) 5106 } 5107 case interface{ Validate() error }: 5108 if err := v.Validate(); err != nil { 5109 errors = append(errors, SetOperation_ChildValidationError{ 5110 field: "XThis", 5111 reason: "embedded message failed validation", 5112 cause: err, 5113 }) 5114 } 5115 } 5116 } else if v, ok := interface{}(m.GetXThis()).(interface{ Validate() error }); ok { 5117 if err := v.Validate(); err != nil { 5118 return SetOperation_ChildValidationError{ 5119 field: "XThis", 5120 reason: "embedded message failed validation", 5121 cause: err, 5122 } 5123 } 5124 } 5125 5126 case *SetOperation_Child_ComputedUserset: 5127 if v == nil { 5128 err := SetOperation_ChildValidationError{ 5129 field: "ChildType", 5130 reason: "oneof value cannot be a typed-nil", 5131 } 5132 if !all { 5133 return err 5134 } 5135 errors = append(errors, err) 5136 } 5137 oneofChildTypePresent = true 5138 5139 if m.GetComputedUserset() == nil { 5140 err := SetOperation_ChildValidationError{ 5141 field: "ComputedUserset", 5142 reason: "value is required", 5143 } 5144 if !all { 5145 return err 5146 } 5147 errors = append(errors, err) 5148 } 5149 5150 if all { 5151 switch v := interface{}(m.GetComputedUserset()).(type) { 5152 case interface{ ValidateAll() error }: 5153 if err := v.ValidateAll(); err != nil { 5154 errors = append(errors, SetOperation_ChildValidationError{ 5155 field: "ComputedUserset", 5156 reason: "embedded message failed validation", 5157 cause: err, 5158 }) 5159 } 5160 case interface{ Validate() error }: 5161 if err := v.Validate(); err != nil { 5162 errors = append(errors, SetOperation_ChildValidationError{ 5163 field: "ComputedUserset", 5164 reason: "embedded message failed validation", 5165 cause: err, 5166 }) 5167 } 5168 } 5169 } else if v, ok := interface{}(m.GetComputedUserset()).(interface{ Validate() error }); ok { 5170 if err := v.Validate(); err != nil { 5171 return SetOperation_ChildValidationError{ 5172 field: "ComputedUserset", 5173 reason: "embedded message failed validation", 5174 cause: err, 5175 } 5176 } 5177 } 5178 5179 case *SetOperation_Child_TupleToUserset: 5180 if v == nil { 5181 err := SetOperation_ChildValidationError{ 5182 field: "ChildType", 5183 reason: "oneof value cannot be a typed-nil", 5184 } 5185 if !all { 5186 return err 5187 } 5188 errors = append(errors, err) 5189 } 5190 oneofChildTypePresent = true 5191 5192 if m.GetTupleToUserset() == nil { 5193 err := SetOperation_ChildValidationError{ 5194 field: "TupleToUserset", 5195 reason: "value is required", 5196 } 5197 if !all { 5198 return err 5199 } 5200 errors = append(errors, err) 5201 } 5202 5203 if all { 5204 switch v := interface{}(m.GetTupleToUserset()).(type) { 5205 case interface{ ValidateAll() error }: 5206 if err := v.ValidateAll(); err != nil { 5207 errors = append(errors, SetOperation_ChildValidationError{ 5208 field: "TupleToUserset", 5209 reason: "embedded message failed validation", 5210 cause: err, 5211 }) 5212 } 5213 case interface{ Validate() error }: 5214 if err := v.Validate(); err != nil { 5215 errors = append(errors, SetOperation_ChildValidationError{ 5216 field: "TupleToUserset", 5217 reason: "embedded message failed validation", 5218 cause: err, 5219 }) 5220 } 5221 } 5222 } else if v, ok := interface{}(m.GetTupleToUserset()).(interface{ Validate() error }); ok { 5223 if err := v.Validate(); err != nil { 5224 return SetOperation_ChildValidationError{ 5225 field: "TupleToUserset", 5226 reason: "embedded message failed validation", 5227 cause: err, 5228 } 5229 } 5230 } 5231 5232 case *SetOperation_Child_UsersetRewrite: 5233 if v == nil { 5234 err := SetOperation_ChildValidationError{ 5235 field: "ChildType", 5236 reason: "oneof value cannot be a typed-nil", 5237 } 5238 if !all { 5239 return err 5240 } 5241 errors = append(errors, err) 5242 } 5243 oneofChildTypePresent = true 5244 5245 if m.GetUsersetRewrite() == nil { 5246 err := SetOperation_ChildValidationError{ 5247 field: "UsersetRewrite", 5248 reason: "value is required", 5249 } 5250 if !all { 5251 return err 5252 } 5253 errors = append(errors, err) 5254 } 5255 5256 if all { 5257 switch v := interface{}(m.GetUsersetRewrite()).(type) { 5258 case interface{ ValidateAll() error }: 5259 if err := v.ValidateAll(); err != nil { 5260 errors = append(errors, SetOperation_ChildValidationError{ 5261 field: "UsersetRewrite", 5262 reason: "embedded message failed validation", 5263 cause: err, 5264 }) 5265 } 5266 case interface{ Validate() error }: 5267 if err := v.Validate(); err != nil { 5268 errors = append(errors, SetOperation_ChildValidationError{ 5269 field: "UsersetRewrite", 5270 reason: "embedded message failed validation", 5271 cause: err, 5272 }) 5273 } 5274 } 5275 } else if v, ok := interface{}(m.GetUsersetRewrite()).(interface{ Validate() error }); ok { 5276 if err := v.Validate(); err != nil { 5277 return SetOperation_ChildValidationError{ 5278 field: "UsersetRewrite", 5279 reason: "embedded message failed validation", 5280 cause: err, 5281 } 5282 } 5283 } 5284 5285 case *SetOperation_Child_XNil: 5286 if v == nil { 5287 err := SetOperation_ChildValidationError{ 5288 field: "ChildType", 5289 reason: "oneof value cannot be a typed-nil", 5290 } 5291 if !all { 5292 return err 5293 } 5294 errors = append(errors, err) 5295 } 5296 oneofChildTypePresent = true 5297 5298 if all { 5299 switch v := interface{}(m.GetXNil()).(type) { 5300 case interface{ ValidateAll() error }: 5301 if err := v.ValidateAll(); err != nil { 5302 errors = append(errors, SetOperation_ChildValidationError{ 5303 field: "XNil", 5304 reason: "embedded message failed validation", 5305 cause: err, 5306 }) 5307 } 5308 case interface{ Validate() error }: 5309 if err := v.Validate(); err != nil { 5310 errors = append(errors, SetOperation_ChildValidationError{ 5311 field: "XNil", 5312 reason: "embedded message failed validation", 5313 cause: err, 5314 }) 5315 } 5316 } 5317 } else if v, ok := interface{}(m.GetXNil()).(interface{ Validate() error }); ok { 5318 if err := v.Validate(); err != nil { 5319 return SetOperation_ChildValidationError{ 5320 field: "XNil", 5321 reason: "embedded message failed validation", 5322 cause: err, 5323 } 5324 } 5325 } 5326 5327 default: 5328 _ = v // ensures v is used 5329 } 5330 if !oneofChildTypePresent { 5331 err := SetOperation_ChildValidationError{ 5332 field: "ChildType", 5333 reason: "value is required", 5334 } 5335 if !all { 5336 return err 5337 } 5338 errors = append(errors, err) 5339 } 5340 5341 if len(errors) > 0 { 5342 return SetOperation_ChildMultiError(errors) 5343 } 5344 5345 return nil 5346 } 5347 5348 // SetOperation_ChildMultiError is an error wrapping multiple validation errors 5349 // returned by SetOperation_Child.ValidateAll() if the designated constraints 5350 // aren't met. 5351 type SetOperation_ChildMultiError []error 5352 5353 // Error returns a concatenation of all the error messages it wraps. 5354 func (m SetOperation_ChildMultiError) Error() string { 5355 var msgs []string 5356 for _, err := range m { 5357 msgs = append(msgs, err.Error()) 5358 } 5359 return strings.Join(msgs, "; ") 5360 } 5361 5362 // AllErrors returns a list of validation violation errors. 5363 func (m SetOperation_ChildMultiError) AllErrors() []error { return m } 5364 5365 // SetOperation_ChildValidationError is the validation error returned by 5366 // SetOperation_Child.Validate if the designated constraints aren't met. 5367 type SetOperation_ChildValidationError struct { 5368 field string 5369 reason string 5370 cause error 5371 key bool 5372 } 5373 5374 // Field function returns field value. 5375 func (e SetOperation_ChildValidationError) Field() string { return e.field } 5376 5377 // Reason function returns reason value. 5378 func (e SetOperation_ChildValidationError) Reason() string { return e.reason } 5379 5380 // Cause function returns cause value. 5381 func (e SetOperation_ChildValidationError) Cause() error { return e.cause } 5382 5383 // Key function returns key value. 5384 func (e SetOperation_ChildValidationError) Key() bool { return e.key } 5385 5386 // ErrorName returns error name. 5387 func (e SetOperation_ChildValidationError) ErrorName() string { 5388 return "SetOperation_ChildValidationError" 5389 } 5390 5391 // Error satisfies the builtin error interface 5392 func (e SetOperation_ChildValidationError) Error() string { 5393 cause := "" 5394 if e.cause != nil { 5395 cause = fmt.Sprintf(" | caused by: %v", e.cause) 5396 } 5397 5398 key := "" 5399 if e.key { 5400 key = "key for " 5401 } 5402 5403 return fmt.Sprintf( 5404 "invalid %sSetOperation_Child.%s: %s%s", 5405 key, 5406 e.field, 5407 e.reason, 5408 cause) 5409 } 5410 5411 var _ error = SetOperation_ChildValidationError{} 5412 5413 var _ interface { 5414 Field() string 5415 Reason() string 5416 Key() bool 5417 Cause() error 5418 ErrorName() string 5419 } = SetOperation_ChildValidationError{} 5420 5421 // Validate checks the field values on SetOperation_Child_This with the rules 5422 // defined in the proto definition for this message. If any rules are 5423 // violated, the first error encountered is returned, or nil if there are no violations. 5424 func (m *SetOperation_Child_This) Validate() error { 5425 return m.validate(false) 5426 } 5427 5428 // ValidateAll checks the field values on SetOperation_Child_This with the 5429 // rules defined in the proto definition for this message. If any rules are 5430 // violated, the result is a list of violation errors wrapped in 5431 // SetOperation_Child_ThisMultiError, or nil if none found. 5432 func (m *SetOperation_Child_This) ValidateAll() error { 5433 return m.validate(true) 5434 } 5435 5436 func (m *SetOperation_Child_This) validate(all bool) error { 5437 if m == nil { 5438 return nil 5439 } 5440 5441 var errors []error 5442 5443 if len(errors) > 0 { 5444 return SetOperation_Child_ThisMultiError(errors) 5445 } 5446 5447 return nil 5448 } 5449 5450 // SetOperation_Child_ThisMultiError is an error wrapping multiple validation 5451 // errors returned by SetOperation_Child_This.ValidateAll() if the designated 5452 // constraints aren't met. 5453 type SetOperation_Child_ThisMultiError []error 5454 5455 // Error returns a concatenation of all the error messages it wraps. 5456 func (m SetOperation_Child_ThisMultiError) Error() string { 5457 var msgs []string 5458 for _, err := range m { 5459 msgs = append(msgs, err.Error()) 5460 } 5461 return strings.Join(msgs, "; ") 5462 } 5463 5464 // AllErrors returns a list of validation violation errors. 5465 func (m SetOperation_Child_ThisMultiError) AllErrors() []error { return m } 5466 5467 // SetOperation_Child_ThisValidationError is the validation error returned by 5468 // SetOperation_Child_This.Validate if the designated constraints aren't met. 5469 type SetOperation_Child_ThisValidationError struct { 5470 field string 5471 reason string 5472 cause error 5473 key bool 5474 } 5475 5476 // Field function returns field value. 5477 func (e SetOperation_Child_ThisValidationError) Field() string { return e.field } 5478 5479 // Reason function returns reason value. 5480 func (e SetOperation_Child_ThisValidationError) Reason() string { return e.reason } 5481 5482 // Cause function returns cause value. 5483 func (e SetOperation_Child_ThisValidationError) Cause() error { return e.cause } 5484 5485 // Key function returns key value. 5486 func (e SetOperation_Child_ThisValidationError) Key() bool { return e.key } 5487 5488 // ErrorName returns error name. 5489 func (e SetOperation_Child_ThisValidationError) ErrorName() string { 5490 return "SetOperation_Child_ThisValidationError" 5491 } 5492 5493 // Error satisfies the builtin error interface 5494 func (e SetOperation_Child_ThisValidationError) Error() string { 5495 cause := "" 5496 if e.cause != nil { 5497 cause = fmt.Sprintf(" | caused by: %v", e.cause) 5498 } 5499 5500 key := "" 5501 if e.key { 5502 key = "key for " 5503 } 5504 5505 return fmt.Sprintf( 5506 "invalid %sSetOperation_Child_This.%s: %s%s", 5507 key, 5508 e.field, 5509 e.reason, 5510 cause) 5511 } 5512 5513 var _ error = SetOperation_Child_ThisValidationError{} 5514 5515 var _ interface { 5516 Field() string 5517 Reason() string 5518 Key() bool 5519 Cause() error 5520 ErrorName() string 5521 } = SetOperation_Child_ThisValidationError{} 5522 5523 // Validate checks the field values on SetOperation_Child_Nil with the rules 5524 // defined in the proto definition for this message. If any rules are 5525 // violated, the first error encountered is returned, or nil if there are no violations. 5526 func (m *SetOperation_Child_Nil) Validate() error { 5527 return m.validate(false) 5528 } 5529 5530 // ValidateAll checks the field values on SetOperation_Child_Nil with the rules 5531 // defined in the proto definition for this message. If any rules are 5532 // violated, the result is a list of violation errors wrapped in 5533 // SetOperation_Child_NilMultiError, or nil if none found. 5534 func (m *SetOperation_Child_Nil) ValidateAll() error { 5535 return m.validate(true) 5536 } 5537 5538 func (m *SetOperation_Child_Nil) validate(all bool) error { 5539 if m == nil { 5540 return nil 5541 } 5542 5543 var errors []error 5544 5545 if len(errors) > 0 { 5546 return SetOperation_Child_NilMultiError(errors) 5547 } 5548 5549 return nil 5550 } 5551 5552 // SetOperation_Child_NilMultiError is an error wrapping multiple validation 5553 // errors returned by SetOperation_Child_Nil.ValidateAll() if the designated 5554 // constraints aren't met. 5555 type SetOperation_Child_NilMultiError []error 5556 5557 // Error returns a concatenation of all the error messages it wraps. 5558 func (m SetOperation_Child_NilMultiError) Error() string { 5559 var msgs []string 5560 for _, err := range m { 5561 msgs = append(msgs, err.Error()) 5562 } 5563 return strings.Join(msgs, "; ") 5564 } 5565 5566 // AllErrors returns a list of validation violation errors. 5567 func (m SetOperation_Child_NilMultiError) AllErrors() []error { return m } 5568 5569 // SetOperation_Child_NilValidationError is the validation error returned by 5570 // SetOperation_Child_Nil.Validate if the designated constraints aren't met. 5571 type SetOperation_Child_NilValidationError struct { 5572 field string 5573 reason string 5574 cause error 5575 key bool 5576 } 5577 5578 // Field function returns field value. 5579 func (e SetOperation_Child_NilValidationError) Field() string { return e.field } 5580 5581 // Reason function returns reason value. 5582 func (e SetOperation_Child_NilValidationError) Reason() string { return e.reason } 5583 5584 // Cause function returns cause value. 5585 func (e SetOperation_Child_NilValidationError) Cause() error { return e.cause } 5586 5587 // Key function returns key value. 5588 func (e SetOperation_Child_NilValidationError) Key() bool { return e.key } 5589 5590 // ErrorName returns error name. 5591 func (e SetOperation_Child_NilValidationError) ErrorName() string { 5592 return "SetOperation_Child_NilValidationError" 5593 } 5594 5595 // Error satisfies the builtin error interface 5596 func (e SetOperation_Child_NilValidationError) Error() string { 5597 cause := "" 5598 if e.cause != nil { 5599 cause = fmt.Sprintf(" | caused by: %v", e.cause) 5600 } 5601 5602 key := "" 5603 if e.key { 5604 key = "key for " 5605 } 5606 5607 return fmt.Sprintf( 5608 "invalid %sSetOperation_Child_Nil.%s: %s%s", 5609 key, 5610 e.field, 5611 e.reason, 5612 cause) 5613 } 5614 5615 var _ error = SetOperation_Child_NilValidationError{} 5616 5617 var _ interface { 5618 Field() string 5619 Reason() string 5620 Key() bool 5621 Cause() error 5622 ErrorName() string 5623 } = SetOperation_Child_NilValidationError{} 5624 5625 // Validate checks the field values on TupleToUserset_Tupleset with the rules 5626 // defined in the proto definition for this message. If any rules are 5627 // violated, the first error encountered is returned, or nil if there are no violations. 5628 func (m *TupleToUserset_Tupleset) Validate() error { 5629 return m.validate(false) 5630 } 5631 5632 // ValidateAll checks the field values on TupleToUserset_Tupleset with the 5633 // rules defined in the proto definition for this message. If any rules are 5634 // violated, the result is a list of violation errors wrapped in 5635 // TupleToUserset_TuplesetMultiError, or nil if none found. 5636 func (m *TupleToUserset_Tupleset) ValidateAll() error { 5637 return m.validate(true) 5638 } 5639 5640 func (m *TupleToUserset_Tupleset) validate(all bool) error { 5641 if m == nil { 5642 return nil 5643 } 5644 5645 var errors []error 5646 5647 if len(m.GetRelation()) > 64 { 5648 err := TupleToUserset_TuplesetValidationError{ 5649 field: "Relation", 5650 reason: "value length must be at most 64 bytes", 5651 } 5652 if !all { 5653 return err 5654 } 5655 errors = append(errors, err) 5656 } 5657 5658 if !_TupleToUserset_Tupleset_Relation_Pattern.MatchString(m.GetRelation()) { 5659 err := TupleToUserset_TuplesetValidationError{ 5660 field: "Relation", 5661 reason: "value does not match regex pattern \"^[a-z][a-z0-9_]{1,62}[a-z0-9]$\"", 5662 } 5663 if !all { 5664 return err 5665 } 5666 errors = append(errors, err) 5667 } 5668 5669 if len(errors) > 0 { 5670 return TupleToUserset_TuplesetMultiError(errors) 5671 } 5672 5673 return nil 5674 } 5675 5676 // TupleToUserset_TuplesetMultiError is an error wrapping multiple validation 5677 // errors returned by TupleToUserset_Tupleset.ValidateAll() if the designated 5678 // constraints aren't met. 5679 type TupleToUserset_TuplesetMultiError []error 5680 5681 // Error returns a concatenation of all the error messages it wraps. 5682 func (m TupleToUserset_TuplesetMultiError) Error() string { 5683 var msgs []string 5684 for _, err := range m { 5685 msgs = append(msgs, err.Error()) 5686 } 5687 return strings.Join(msgs, "; ") 5688 } 5689 5690 // AllErrors returns a list of validation violation errors. 5691 func (m TupleToUserset_TuplesetMultiError) AllErrors() []error { return m } 5692 5693 // TupleToUserset_TuplesetValidationError is the validation error returned by 5694 // TupleToUserset_Tupleset.Validate if the designated constraints aren't met. 5695 type TupleToUserset_TuplesetValidationError struct { 5696 field string 5697 reason string 5698 cause error 5699 key bool 5700 } 5701 5702 // Field function returns field value. 5703 func (e TupleToUserset_TuplesetValidationError) Field() string { return e.field } 5704 5705 // Reason function returns reason value. 5706 func (e TupleToUserset_TuplesetValidationError) Reason() string { return e.reason } 5707 5708 // Cause function returns cause value. 5709 func (e TupleToUserset_TuplesetValidationError) Cause() error { return e.cause } 5710 5711 // Key function returns key value. 5712 func (e TupleToUserset_TuplesetValidationError) Key() bool { return e.key } 5713 5714 // ErrorName returns error name. 5715 func (e TupleToUserset_TuplesetValidationError) ErrorName() string { 5716 return "TupleToUserset_TuplesetValidationError" 5717 } 5718 5719 // Error satisfies the builtin error interface 5720 func (e TupleToUserset_TuplesetValidationError) Error() string { 5721 cause := "" 5722 if e.cause != nil { 5723 cause = fmt.Sprintf(" | caused by: %v", e.cause) 5724 } 5725 5726 key := "" 5727 if e.key { 5728 key = "key for " 5729 } 5730 5731 return fmt.Sprintf( 5732 "invalid %sTupleToUserset_Tupleset.%s: %s%s", 5733 key, 5734 e.field, 5735 e.reason, 5736 cause) 5737 } 5738 5739 var _ error = TupleToUserset_TuplesetValidationError{} 5740 5741 var _ interface { 5742 Field() string 5743 Reason() string 5744 Key() bool 5745 Cause() error 5746 ErrorName() string 5747 } = TupleToUserset_TuplesetValidationError{} 5748 5749 var _TupleToUserset_Tupleset_Relation_Pattern = regexp.MustCompile("^[a-z][a-z0-9_]{1,62}[a-z0-9]$")