1// Code generated by protoc-gen-validate. DO NOT EDIT. 2// source: envoy/config/core/v3/config_source.proto 3 4package envoy_config_core_v3 5 6import ( 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 23var ( 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 ApiConfigSource with the rules defined 39// in the proto definition for this message. If any rules are violated, the 40// first error encountered is returned, or nil if there are no violations. 41func (m *ApiConfigSource) Validate() error { 42 return m.validate(false) 43} 44 45// ValidateAll checks the field values on ApiConfigSource with the rules 46// defined in the proto definition for this message. If any rules are 47// violated, the result is a list of violation errors wrapped in 48// ApiConfigSourceMultiError, or nil if none found. 49func (m *ApiConfigSource) ValidateAll() error { 50 return m.validate(true) 51} 52 53func (m *ApiConfigSource) validate(all bool) error { 54 if m == nil { 55 return nil 56 } 57 58 var errors []error 59 60 if _, ok := ApiConfigSource_ApiType_name[int32(m.GetApiType())]; !ok { 61 err := ApiConfigSourceValidationError{ 62 field: "ApiType", 63 reason: "value must be one of the defined enum values", 64 } 65 if !all { 66 return err 67 } 68 errors = append(errors, err) 69 } 70 71 if _, ok := ApiVersion_name[int32(m.GetTransportApiVersion())]; !ok { 72 err := ApiConfigSourceValidationError{ 73 field: "TransportApiVersion", 74 reason: "value must be one of the defined enum values", 75 } 76 if !all { 77 return err 78 } 79 errors = append(errors, err) 80 } 81 82 for idx, item := range m.GetGrpcServices() { 83 _, _ = idx, item 84 85 if all { 86 switch v := interface{}(item).(type) { 87 case interface{ ValidateAll() error }: 88 if err := v.ValidateAll(); err != nil { 89 errors = append(errors, ApiConfigSourceValidationError{ 90 field: fmt.Sprintf("GrpcServices[%v]", idx), 91 reason: "embedded message failed validation", 92 cause: err, 93 }) 94 } 95 case interface{ Validate() error }: 96 if err := v.Validate(); err != nil { 97 errors = append(errors, ApiConfigSourceValidationError{ 98 field: fmt.Sprintf("GrpcServices[%v]", idx), 99 reason: "embedded message failed validation", 100 cause: err, 101 }) 102 } 103 } 104 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { 105 if err := v.Validate(); err != nil { 106 return ApiConfigSourceValidationError{ 107 field: fmt.Sprintf("GrpcServices[%v]", idx), 108 reason: "embedded message failed validation", 109 cause: err, 110 } 111 } 112 } 113 114 } 115 116 if all { 117 switch v := interface{}(m.GetRefreshDelay()).(type) { 118 case interface{ ValidateAll() error }: 119 if err := v.ValidateAll(); err != nil { 120 errors = append(errors, ApiConfigSourceValidationError{ 121 field: "RefreshDelay", 122 reason: "embedded message failed validation", 123 cause: err, 124 }) 125 } 126 case interface{ Validate() error }: 127 if err := v.Validate(); err != nil { 128 errors = append(errors, ApiConfigSourceValidationError{ 129 field: "RefreshDelay", 130 reason: "embedded message failed validation", 131 cause: err, 132 }) 133 } 134 } 135 } else if v, ok := interface{}(m.GetRefreshDelay()).(interface{ Validate() error }); ok { 136 if err := v.Validate(); err != nil { 137 return ApiConfigSourceValidationError{ 138 field: "RefreshDelay", 139 reason: "embedded message failed validation", 140 cause: err, 141 } 142 } 143 } 144 145 if d := m.GetRequestTimeout(); d != nil { 146 dur, err := d.AsDuration(), d.CheckValid() 147 if err != nil { 148 err = ApiConfigSourceValidationError{ 149 field: "RequestTimeout", 150 reason: "value is not a valid duration", 151 cause: err, 152 } 153 if !all { 154 return err 155 } 156 errors = append(errors, err) 157 } else { 158 159 gt := time.Duration(0*time.Second + 0*time.Nanosecond) 160 161 if dur <= gt { 162 err := ApiConfigSourceValidationError{ 163 field: "RequestTimeout", 164 reason: "value must be greater than 0s", 165 } 166 if !all { 167 return err 168 } 169 errors = append(errors, err) 170 } 171 172 } 173 } 174 175 if all { 176 switch v := interface{}(m.GetRateLimitSettings()).(type) { 177 case interface{ ValidateAll() error }: 178 if err := v.ValidateAll(); err != nil { 179 errors = append(errors, ApiConfigSourceValidationError{ 180 field: "RateLimitSettings", 181 reason: "embedded message failed validation", 182 cause: err, 183 }) 184 } 185 case interface{ Validate() error }: 186 if err := v.Validate(); err != nil { 187 errors = append(errors, ApiConfigSourceValidationError{ 188 field: "RateLimitSettings", 189 reason: "embedded message failed validation", 190 cause: err, 191 }) 192 } 193 } 194 } else if v, ok := interface{}(m.GetRateLimitSettings()).(interface{ Validate() error }); ok { 195 if err := v.Validate(); err != nil { 196 return ApiConfigSourceValidationError{ 197 field: "RateLimitSettings", 198 reason: "embedded message failed validation", 199 cause: err, 200 } 201 } 202 } 203 204 // no validation rules for SetNodeOnFirstMessageOnly 205 206 if len(errors) > 0 { 207 return ApiConfigSourceMultiError(errors) 208 } 209 return nil 210} 211 212// ApiConfigSourceMultiError is an error wrapping multiple validation errors 213// returned by ApiConfigSource.ValidateAll() if the designated constraints 214// aren't met. 215type ApiConfigSourceMultiError []error 216 217// Error returns a concatenation of all the error messages it wraps. 218func (m ApiConfigSourceMultiError) Error() string { 219 var msgs []string 220 for _, err := range m { 221 msgs = append(msgs, err.Error()) 222 } 223 return strings.Join(msgs, "; ") 224} 225 226// AllErrors returns a list of validation violation errors. 227func (m ApiConfigSourceMultiError) AllErrors() []error { return m } 228 229// ApiConfigSourceValidationError is the validation error returned by 230// ApiConfigSource.Validate if the designated constraints aren't met. 231type ApiConfigSourceValidationError struct { 232 field string 233 reason string 234 cause error 235 key bool 236} 237 238// Field function returns field value. 239func (e ApiConfigSourceValidationError) Field() string { return e.field } 240 241// Reason function returns reason value. 242func (e ApiConfigSourceValidationError) Reason() string { return e.reason } 243 244// Cause function returns cause value. 245func (e ApiConfigSourceValidationError) Cause() error { return e.cause } 246 247// Key function returns key value. 248func (e ApiConfigSourceValidationError) Key() bool { return e.key } 249 250// ErrorName returns error name. 251func (e ApiConfigSourceValidationError) ErrorName() string { return "ApiConfigSourceValidationError" } 252 253// Error satisfies the builtin error interface 254func (e ApiConfigSourceValidationError) Error() string { 255 cause := "" 256 if e.cause != nil { 257 cause = fmt.Sprintf(" | caused by: %v", e.cause) 258 } 259 260 key := "" 261 if e.key { 262 key = "key for " 263 } 264 265 return fmt.Sprintf( 266 "invalid %sApiConfigSource.%s: %s%s", 267 key, 268 e.field, 269 e.reason, 270 cause) 271} 272 273var _ error = ApiConfigSourceValidationError{} 274 275var _ interface { 276 Field() string 277 Reason() string 278 Key() bool 279 Cause() error 280 ErrorName() string 281} = ApiConfigSourceValidationError{} 282 283// Validate checks the field values on AggregatedConfigSource with the rules 284// defined in the proto definition for this message. If any rules are 285// violated, the first error encountered is returned, or nil if there are no violations. 286func (m *AggregatedConfigSource) Validate() error { 287 return m.validate(false) 288} 289 290// ValidateAll checks the field values on AggregatedConfigSource with the rules 291// defined in the proto definition for this message. If any rules are 292// violated, the result is a list of violation errors wrapped in 293// AggregatedConfigSourceMultiError, or nil if none found. 294func (m *AggregatedConfigSource) ValidateAll() error { 295 return m.validate(true) 296} 297 298func (m *AggregatedConfigSource) validate(all bool) error { 299 if m == nil { 300 return nil 301 } 302 303 var errors []error 304 305 if len(errors) > 0 { 306 return AggregatedConfigSourceMultiError(errors) 307 } 308 return nil 309} 310 311// AggregatedConfigSourceMultiError is an error wrapping multiple validation 312// errors returned by AggregatedConfigSource.ValidateAll() if the designated 313// constraints aren't met. 314type AggregatedConfigSourceMultiError []error 315 316// Error returns a concatenation of all the error messages it wraps. 317func (m AggregatedConfigSourceMultiError) Error() string { 318 var msgs []string 319 for _, err := range m { 320 msgs = append(msgs, err.Error()) 321 } 322 return strings.Join(msgs, "; ") 323} 324 325// AllErrors returns a list of validation violation errors. 326func (m AggregatedConfigSourceMultiError) AllErrors() []error { return m } 327 328// AggregatedConfigSourceValidationError is the validation error returned by 329// AggregatedConfigSource.Validate if the designated constraints aren't met. 330type AggregatedConfigSourceValidationError struct { 331 field string 332 reason string 333 cause error 334 key bool 335} 336 337// Field function returns field value. 338func (e AggregatedConfigSourceValidationError) Field() string { return e.field } 339 340// Reason function returns reason value. 341func (e AggregatedConfigSourceValidationError) Reason() string { return e.reason } 342 343// Cause function returns cause value. 344func (e AggregatedConfigSourceValidationError) Cause() error { return e.cause } 345 346// Key function returns key value. 347func (e AggregatedConfigSourceValidationError) Key() bool { return e.key } 348 349// ErrorName returns error name. 350func (e AggregatedConfigSourceValidationError) ErrorName() string { 351 return "AggregatedConfigSourceValidationError" 352} 353 354// Error satisfies the builtin error interface 355func (e AggregatedConfigSourceValidationError) Error() string { 356 cause := "" 357 if e.cause != nil { 358 cause = fmt.Sprintf(" | caused by: %v", e.cause) 359 } 360 361 key := "" 362 if e.key { 363 key = "key for " 364 } 365 366 return fmt.Sprintf( 367 "invalid %sAggregatedConfigSource.%s: %s%s", 368 key, 369 e.field, 370 e.reason, 371 cause) 372} 373 374var _ error = AggregatedConfigSourceValidationError{} 375 376var _ interface { 377 Field() string 378 Reason() string 379 Key() bool 380 Cause() error 381 ErrorName() string 382} = AggregatedConfigSourceValidationError{} 383 384// Validate checks the field values on SelfConfigSource with the rules defined 385// in the proto definition for this message. If any rules are violated, the 386// first error encountered is returned, or nil if there are no violations. 387func (m *SelfConfigSource) Validate() error { 388 return m.validate(false) 389} 390 391// ValidateAll checks the field values on SelfConfigSource with the rules 392// defined in the proto definition for this message. If any rules are 393// violated, the result is a list of violation errors wrapped in 394// SelfConfigSourceMultiError, or nil if none found. 395func (m *SelfConfigSource) ValidateAll() error { 396 return m.validate(true) 397} 398 399func (m *SelfConfigSource) validate(all bool) error { 400 if m == nil { 401 return nil 402 } 403 404 var errors []error 405 406 if _, ok := ApiVersion_name[int32(m.GetTransportApiVersion())]; !ok { 407 err := SelfConfigSourceValidationError{ 408 field: "TransportApiVersion", 409 reason: "value must be one of the defined enum values", 410 } 411 if !all { 412 return err 413 } 414 errors = append(errors, err) 415 } 416 417 if len(errors) > 0 { 418 return SelfConfigSourceMultiError(errors) 419 } 420 return nil 421} 422 423// SelfConfigSourceMultiError is an error wrapping multiple validation errors 424// returned by SelfConfigSource.ValidateAll() if the designated constraints 425// aren't met. 426type SelfConfigSourceMultiError []error 427 428// Error returns a concatenation of all the error messages it wraps. 429func (m SelfConfigSourceMultiError) Error() string { 430 var msgs []string 431 for _, err := range m { 432 msgs = append(msgs, err.Error()) 433 } 434 return strings.Join(msgs, "; ") 435} 436 437// AllErrors returns a list of validation violation errors. 438func (m SelfConfigSourceMultiError) AllErrors() []error { return m } 439 440// SelfConfigSourceValidationError is the validation error returned by 441// SelfConfigSource.Validate if the designated constraints aren't met. 442type SelfConfigSourceValidationError struct { 443 field string 444 reason string 445 cause error 446 key bool 447} 448 449// Field function returns field value. 450func (e SelfConfigSourceValidationError) Field() string { return e.field } 451 452// Reason function returns reason value. 453func (e SelfConfigSourceValidationError) Reason() string { return e.reason } 454 455// Cause function returns cause value. 456func (e SelfConfigSourceValidationError) Cause() error { return e.cause } 457 458// Key function returns key value. 459func (e SelfConfigSourceValidationError) Key() bool { return e.key } 460 461// ErrorName returns error name. 462func (e SelfConfigSourceValidationError) ErrorName() string { return "SelfConfigSourceValidationError" } 463 464// Error satisfies the builtin error interface 465func (e SelfConfigSourceValidationError) Error() string { 466 cause := "" 467 if e.cause != nil { 468 cause = fmt.Sprintf(" | caused by: %v", e.cause) 469 } 470 471 key := "" 472 if e.key { 473 key = "key for " 474 } 475 476 return fmt.Sprintf( 477 "invalid %sSelfConfigSource.%s: %s%s", 478 key, 479 e.field, 480 e.reason, 481 cause) 482} 483 484var _ error = SelfConfigSourceValidationError{} 485 486var _ interface { 487 Field() string 488 Reason() string 489 Key() bool 490 Cause() error 491 ErrorName() string 492} = SelfConfigSourceValidationError{} 493 494// Validate checks the field values on RateLimitSettings with the rules defined 495// in the proto definition for this message. If any rules are violated, the 496// first error encountered is returned, or nil if there are no violations. 497func (m *RateLimitSettings) Validate() error { 498 return m.validate(false) 499} 500 501// ValidateAll checks the field values on RateLimitSettings with the rules 502// defined in the proto definition for this message. If any rules are 503// violated, the result is a list of violation errors wrapped in 504// RateLimitSettingsMultiError, or nil if none found. 505func (m *RateLimitSettings) ValidateAll() error { 506 return m.validate(true) 507} 508 509func (m *RateLimitSettings) validate(all bool) error { 510 if m == nil { 511 return nil 512 } 513 514 var errors []error 515 516 if all { 517 switch v := interface{}(m.GetMaxTokens()).(type) { 518 case interface{ ValidateAll() error }: 519 if err := v.ValidateAll(); err != nil { 520 errors = append(errors, RateLimitSettingsValidationError{ 521 field: "MaxTokens", 522 reason: "embedded message failed validation", 523 cause: err, 524 }) 525 } 526 case interface{ Validate() error }: 527 if err := v.Validate(); err != nil { 528 errors = append(errors, RateLimitSettingsValidationError{ 529 field: "MaxTokens", 530 reason: "embedded message failed validation", 531 cause: err, 532 }) 533 } 534 } 535 } else if v, ok := interface{}(m.GetMaxTokens()).(interface{ Validate() error }); ok { 536 if err := v.Validate(); err != nil { 537 return RateLimitSettingsValidationError{ 538 field: "MaxTokens", 539 reason: "embedded message failed validation", 540 cause: err, 541 } 542 } 543 } 544 545 if wrapper := m.GetFillRate(); wrapper != nil { 546 547 if wrapper.GetValue() <= 0 { 548 err := RateLimitSettingsValidationError{ 549 field: "FillRate", 550 reason: "value must be greater than 0", 551 } 552 if !all { 553 return err 554 } 555 errors = append(errors, err) 556 } 557 558 } 559 560 if len(errors) > 0 { 561 return RateLimitSettingsMultiError(errors) 562 } 563 return nil 564} 565 566// RateLimitSettingsMultiError is an error wrapping multiple validation errors 567// returned by RateLimitSettings.ValidateAll() if the designated constraints 568// aren't met. 569type RateLimitSettingsMultiError []error 570 571// Error returns a concatenation of all the error messages it wraps. 572func (m RateLimitSettingsMultiError) Error() string { 573 var msgs []string 574 for _, err := range m { 575 msgs = append(msgs, err.Error()) 576 } 577 return strings.Join(msgs, "; ") 578} 579 580// AllErrors returns a list of validation violation errors. 581func (m RateLimitSettingsMultiError) AllErrors() []error { return m } 582 583// RateLimitSettingsValidationError is the validation error returned by 584// RateLimitSettings.Validate if the designated constraints aren't met. 585type RateLimitSettingsValidationError struct { 586 field string 587 reason string 588 cause error 589 key bool 590} 591 592// Field function returns field value. 593func (e RateLimitSettingsValidationError) Field() string { return e.field } 594 595// Reason function returns reason value. 596func (e RateLimitSettingsValidationError) Reason() string { return e.reason } 597 598// Cause function returns cause value. 599func (e RateLimitSettingsValidationError) Cause() error { return e.cause } 600 601// Key function returns key value. 602func (e RateLimitSettingsValidationError) Key() bool { return e.key } 603 604// ErrorName returns error name. 605func (e RateLimitSettingsValidationError) ErrorName() string { 606 return "RateLimitSettingsValidationError" 607} 608 609// Error satisfies the builtin error interface 610func (e RateLimitSettingsValidationError) Error() string { 611 cause := "" 612 if e.cause != nil { 613 cause = fmt.Sprintf(" | caused by: %v", e.cause) 614 } 615 616 key := "" 617 if e.key { 618 key = "key for " 619 } 620 621 return fmt.Sprintf( 622 "invalid %sRateLimitSettings.%s: %s%s", 623 key, 624 e.field, 625 e.reason, 626 cause) 627} 628 629var _ error = RateLimitSettingsValidationError{} 630 631var _ interface { 632 Field() string 633 Reason() string 634 Key() bool 635 Cause() error 636 ErrorName() string 637} = RateLimitSettingsValidationError{} 638 639// Validate checks the field values on ConfigSource with the rules defined in 640// the proto definition for this message. If any rules are violated, the first 641// error encountered is returned, or nil if there are no violations. 642func (m *ConfigSource) Validate() error { 643 return m.validate(false) 644} 645 646// ValidateAll checks the field values on ConfigSource with the rules defined 647// in the proto definition for this message. If any rules are violated, the 648// result is a list of violation errors wrapped in ConfigSourceMultiError, or 649// nil if none found. 650func (m *ConfigSource) ValidateAll() error { 651 return m.validate(true) 652} 653 654func (m *ConfigSource) validate(all bool) error { 655 if m == nil { 656 return nil 657 } 658 659 var errors []error 660 661 for idx, item := range m.GetAuthorities() { 662 _, _ = idx, item 663 664 if all { 665 switch v := interface{}(item).(type) { 666 case interface{ ValidateAll() error }: 667 if err := v.ValidateAll(); err != nil { 668 errors = append(errors, ConfigSourceValidationError{ 669 field: fmt.Sprintf("Authorities[%v]", idx), 670 reason: "embedded message failed validation", 671 cause: err, 672 }) 673 } 674 case interface{ Validate() error }: 675 if err := v.Validate(); err != nil { 676 errors = append(errors, ConfigSourceValidationError{ 677 field: fmt.Sprintf("Authorities[%v]", idx), 678 reason: "embedded message failed validation", 679 cause: err, 680 }) 681 } 682 } 683 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { 684 if err := v.Validate(); err != nil { 685 return ConfigSourceValidationError{ 686 field: fmt.Sprintf("Authorities[%v]", idx), 687 reason: "embedded message failed validation", 688 cause: err, 689 } 690 } 691 } 692 693 } 694 695 if all { 696 switch v := interface{}(m.GetInitialFetchTimeout()).(type) { 697 case interface{ ValidateAll() error }: 698 if err := v.ValidateAll(); err != nil { 699 errors = append(errors, ConfigSourceValidationError{ 700 field: "InitialFetchTimeout", 701 reason: "embedded message failed validation", 702 cause: err, 703 }) 704 } 705 case interface{ Validate() error }: 706 if err := v.Validate(); err != nil { 707 errors = append(errors, ConfigSourceValidationError{ 708 field: "InitialFetchTimeout", 709 reason: "embedded message failed validation", 710 cause: err, 711 }) 712 } 713 } 714 } else if v, ok := interface{}(m.GetInitialFetchTimeout()).(interface{ Validate() error }); ok { 715 if err := v.Validate(); err != nil { 716 return ConfigSourceValidationError{ 717 field: "InitialFetchTimeout", 718 reason: "embedded message failed validation", 719 cause: err, 720 } 721 } 722 } 723 724 if _, ok := ApiVersion_name[int32(m.GetResourceApiVersion())]; !ok { 725 err := ConfigSourceValidationError{ 726 field: "ResourceApiVersion", 727 reason: "value must be one of the defined enum values", 728 } 729 if !all { 730 return err 731 } 732 errors = append(errors, err) 733 } 734 735 switch m.ConfigSourceSpecifier.(type) { 736 737 case *ConfigSource_Path: 738 // no validation rules for Path 739 740 case *ConfigSource_ApiConfigSource: 741 742 if all { 743 switch v := interface{}(m.GetApiConfigSource()).(type) { 744 case interface{ ValidateAll() error }: 745 if err := v.ValidateAll(); err != nil { 746 errors = append(errors, ConfigSourceValidationError{ 747 field: "ApiConfigSource", 748 reason: "embedded message failed validation", 749 cause: err, 750 }) 751 } 752 case interface{ Validate() error }: 753 if err := v.Validate(); err != nil { 754 errors = append(errors, ConfigSourceValidationError{ 755 field: "ApiConfigSource", 756 reason: "embedded message failed validation", 757 cause: err, 758 }) 759 } 760 } 761 } else if v, ok := interface{}(m.GetApiConfigSource()).(interface{ Validate() error }); ok { 762 if err := v.Validate(); err != nil { 763 return ConfigSourceValidationError{ 764 field: "ApiConfigSource", 765 reason: "embedded message failed validation", 766 cause: err, 767 } 768 } 769 } 770 771 case *ConfigSource_Ads: 772 773 if all { 774 switch v := interface{}(m.GetAds()).(type) { 775 case interface{ ValidateAll() error }: 776 if err := v.ValidateAll(); err != nil { 777 errors = append(errors, ConfigSourceValidationError{ 778 field: "Ads", 779 reason: "embedded message failed validation", 780 cause: err, 781 }) 782 } 783 case interface{ Validate() error }: 784 if err := v.Validate(); err != nil { 785 errors = append(errors, ConfigSourceValidationError{ 786 field: "Ads", 787 reason: "embedded message failed validation", 788 cause: err, 789 }) 790 } 791 } 792 } else if v, ok := interface{}(m.GetAds()).(interface{ Validate() error }); ok { 793 if err := v.Validate(); err != nil { 794 return ConfigSourceValidationError{ 795 field: "Ads", 796 reason: "embedded message failed validation", 797 cause: err, 798 } 799 } 800 } 801 802 case *ConfigSource_Self: 803 804 if all { 805 switch v := interface{}(m.GetSelf()).(type) { 806 case interface{ ValidateAll() error }: 807 if err := v.ValidateAll(); err != nil { 808 errors = append(errors, ConfigSourceValidationError{ 809 field: "Self", 810 reason: "embedded message failed validation", 811 cause: err, 812 }) 813 } 814 case interface{ Validate() error }: 815 if err := v.Validate(); err != nil { 816 errors = append(errors, ConfigSourceValidationError{ 817 field: "Self", 818 reason: "embedded message failed validation", 819 cause: err, 820 }) 821 } 822 } 823 } else if v, ok := interface{}(m.GetSelf()).(interface{ Validate() error }); ok { 824 if err := v.Validate(); err != nil { 825 return ConfigSourceValidationError{ 826 field: "Self", 827 reason: "embedded message failed validation", 828 cause: err, 829 } 830 } 831 } 832 833 default: 834 err := ConfigSourceValidationError{ 835 field: "ConfigSourceSpecifier", 836 reason: "value is required", 837 } 838 if !all { 839 return err 840 } 841 errors = append(errors, err) 842 843 } 844 845 if len(errors) > 0 { 846 return ConfigSourceMultiError(errors) 847 } 848 return nil 849} 850 851// ConfigSourceMultiError is an error wrapping multiple validation errors 852// returned by ConfigSource.ValidateAll() if the designated constraints aren't met. 853type ConfigSourceMultiError []error 854 855// Error returns a concatenation of all the error messages it wraps. 856func (m ConfigSourceMultiError) Error() string { 857 var msgs []string 858 for _, err := range m { 859 msgs = append(msgs, err.Error()) 860 } 861 return strings.Join(msgs, "; ") 862} 863 864// AllErrors returns a list of validation violation errors. 865func (m ConfigSourceMultiError) AllErrors() []error { return m } 866 867// ConfigSourceValidationError is the validation error returned by 868// ConfigSource.Validate if the designated constraints aren't met. 869type ConfigSourceValidationError struct { 870 field string 871 reason string 872 cause error 873 key bool 874} 875 876// Field function returns field value. 877func (e ConfigSourceValidationError) Field() string { return e.field } 878 879// Reason function returns reason value. 880func (e ConfigSourceValidationError) Reason() string { return e.reason } 881 882// Cause function returns cause value. 883func (e ConfigSourceValidationError) Cause() error { return e.cause } 884 885// Key function returns key value. 886func (e ConfigSourceValidationError) Key() bool { return e.key } 887 888// ErrorName returns error name. 889func (e ConfigSourceValidationError) ErrorName() string { return "ConfigSourceValidationError" } 890 891// Error satisfies the builtin error interface 892func (e ConfigSourceValidationError) Error() string { 893 cause := "" 894 if e.cause != nil { 895 cause = fmt.Sprintf(" | caused by: %v", e.cause) 896 } 897 898 key := "" 899 if e.key { 900 key = "key for " 901 } 902 903 return fmt.Sprintf( 904 "invalid %sConfigSource.%s: %s%s", 905 key, 906 e.field, 907 e.reason, 908 cause) 909} 910 911var _ error = ConfigSourceValidationError{} 912 913var _ interface { 914 Field() string 915 Reason() string 916 Key() bool 917 Cause() error 918 ErrorName() string 919} = ConfigSourceValidationError{} 920