//go:build !disable_pgv
// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: contrib/envoy/extensions/filters/http/peer_metadata/v3/peer_metadata.proto

package peer_metadata

import (
	"bytes"
	"errors"
	"fmt"
	"net"
	"net/mail"
	"net/url"
	"regexp"
	"sort"
	"strings"
	"time"
	"unicode/utf8"

	"google.golang.org/protobuf/types/known/anypb"
)

// ensure the imports are used
var (
	_ = bytes.MinRead
	_ = errors.New("")
	_ = fmt.Print
	_ = utf8.UTFMax
	_ = (*regexp.Regexp)(nil)
	_ = (*strings.Reader)(nil)
	_ = net.IPv4len
	_ = time.Duration(0)
	_ = (*url.URL)(nil)
	_ = (*mail.Address)(nil)
	_ = anypb.Any{}
	_ = sort.Sort
)

// Validate checks the field values on Config with the rules defined in the
// proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *Config) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on Config with the rules defined in the
// proto definition for this message. If any rules are violated, the result is
// a list of violation errors wrapped in ConfigMultiError, or nil if none found.
func (m *Config) ValidateAll() error {
	return m.validate(true)
}

func (m *Config) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	for idx, item := range m.GetDownstreamDiscovery() {
		_, _ = idx, item

		if all {
			switch v := interface{}(item).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, ConfigValidationError{
						field:  fmt.Sprintf("DownstreamDiscovery[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, ConfigValidationError{
						field:  fmt.Sprintf("DownstreamDiscovery[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return ConfigValidationError{
					field:  fmt.Sprintf("DownstreamDiscovery[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

	for idx, item := range m.GetUpstreamDiscovery() {
		_, _ = idx, item

		if all {
			switch v := interface{}(item).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, ConfigValidationError{
						field:  fmt.Sprintf("UpstreamDiscovery[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, ConfigValidationError{
						field:  fmt.Sprintf("UpstreamDiscovery[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return ConfigValidationError{
					field:  fmt.Sprintf("UpstreamDiscovery[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

	for idx, item := range m.GetDownstreamPropagation() {
		_, _ = idx, item

		if all {
			switch v := interface{}(item).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, ConfigValidationError{
						field:  fmt.Sprintf("DownstreamPropagation[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, ConfigValidationError{
						field:  fmt.Sprintf("DownstreamPropagation[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return ConfigValidationError{
					field:  fmt.Sprintf("DownstreamPropagation[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

	for idx, item := range m.GetUpstreamPropagation() {
		_, _ = idx, item

		if all {
			switch v := interface{}(item).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, ConfigValidationError{
						field:  fmt.Sprintf("UpstreamPropagation[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, ConfigValidationError{
						field:  fmt.Sprintf("UpstreamPropagation[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return ConfigValidationError{
					field:  fmt.Sprintf("UpstreamPropagation[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

	// no validation rules for SharedWithUpstream

	if len(errors) > 0 {
		return ConfigMultiError(errors)
	}

	return nil
}

// ConfigMultiError is an error wrapping multiple validation errors returned by
// Config.ValidateAll() if the designated constraints aren't met.
type ConfigMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m ConfigMultiError) Error() string {
	msgs := make([]string, 0, len(m))
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m ConfigMultiError) AllErrors() []error { return m }

// ConfigValidationError is the validation error returned by Config.Validate if
// the designated constraints aren't met.
type ConfigValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e ConfigValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e ConfigValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e ConfigValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e ConfigValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e ConfigValidationError) ErrorName() string { return "ConfigValidationError" }

// Error satisfies the builtin error interface
func (e ConfigValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sConfig.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = ConfigValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = ConfigValidationError{}

// Validate checks the field values on Config_Baggage with the rules defined in
// the proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *Config_Baggage) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on Config_Baggage with the rules defined
// in the proto definition for this message. If any rules are violated, the
// result is a list of violation errors wrapped in Config_BaggageMultiError,
// or nil if none found.
func (m *Config_Baggage) ValidateAll() error {
	return m.validate(true)
}

func (m *Config_Baggage) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	if len(errors) > 0 {
		return Config_BaggageMultiError(errors)
	}

	return nil
}

// Config_BaggageMultiError is an error wrapping multiple validation errors
// returned by Config_Baggage.ValidateAll() if the designated constraints
// aren't met.
type Config_BaggageMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m Config_BaggageMultiError) Error() string {
	msgs := make([]string, 0, len(m))
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m Config_BaggageMultiError) AllErrors() []error { return m }

// Config_BaggageValidationError is the validation error returned by
// Config_Baggage.Validate if the designated constraints aren't met.
type Config_BaggageValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e Config_BaggageValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e Config_BaggageValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e Config_BaggageValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e Config_BaggageValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e Config_BaggageValidationError) ErrorName() string { return "Config_BaggageValidationError" }

// Error satisfies the builtin error interface
func (e Config_BaggageValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sConfig_Baggage.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = Config_BaggageValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = Config_BaggageValidationError{}

// Validate checks the field values on Config_WorkloadDiscovery with the rules
// defined in the proto definition for this message. If any rules are
// violated, the first error encountered is returned, or nil if there are no violations.
func (m *Config_WorkloadDiscovery) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on Config_WorkloadDiscovery with the
// rules defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// Config_WorkloadDiscoveryMultiError, or nil if none found.
func (m *Config_WorkloadDiscovery) ValidateAll() error {
	return m.validate(true)
}

func (m *Config_WorkloadDiscovery) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	if len(errors) > 0 {
		return Config_WorkloadDiscoveryMultiError(errors)
	}

	return nil
}

// Config_WorkloadDiscoveryMultiError is an error wrapping multiple validation
// errors returned by Config_WorkloadDiscovery.ValidateAll() if the designated
// constraints aren't met.
type Config_WorkloadDiscoveryMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m Config_WorkloadDiscoveryMultiError) Error() string {
	msgs := make([]string, 0, len(m))
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m Config_WorkloadDiscoveryMultiError) AllErrors() []error { return m }

// Config_WorkloadDiscoveryValidationError is the validation error returned by
// Config_WorkloadDiscovery.Validate if the designated constraints aren't met.
type Config_WorkloadDiscoveryValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e Config_WorkloadDiscoveryValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e Config_WorkloadDiscoveryValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e Config_WorkloadDiscoveryValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e Config_WorkloadDiscoveryValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e Config_WorkloadDiscoveryValidationError) ErrorName() string {
	return "Config_WorkloadDiscoveryValidationError"
}

// Error satisfies the builtin error interface
func (e Config_WorkloadDiscoveryValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sConfig_WorkloadDiscovery.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = Config_WorkloadDiscoveryValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = Config_WorkloadDiscoveryValidationError{}

// Validate checks the field values on Config_IstioHeaders with the rules
// defined in the proto definition for this message. If any rules are
// violated, the first error encountered is returned, or nil if there are no violations.
func (m *Config_IstioHeaders) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on Config_IstioHeaders with the rules
// defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// Config_IstioHeadersMultiError, or nil if none found.
func (m *Config_IstioHeaders) ValidateAll() error {
	return m.validate(true)
}

func (m *Config_IstioHeaders) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	// no validation rules for SkipExternalClusters

	if len(errors) > 0 {
		return Config_IstioHeadersMultiError(errors)
	}

	return nil
}

// Config_IstioHeadersMultiError is an error wrapping multiple validation
// errors returned by Config_IstioHeaders.ValidateAll() if the designated
// constraints aren't met.
type Config_IstioHeadersMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m Config_IstioHeadersMultiError) Error() string {
	msgs := make([]string, 0, len(m))
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m Config_IstioHeadersMultiError) AllErrors() []error { return m }

// Config_IstioHeadersValidationError is the validation error returned by
// Config_IstioHeaders.Validate if the designated constraints aren't met.
type Config_IstioHeadersValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e Config_IstioHeadersValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e Config_IstioHeadersValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e Config_IstioHeadersValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e Config_IstioHeadersValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e Config_IstioHeadersValidationError) ErrorName() string {
	return "Config_IstioHeadersValidationError"
}

// Error satisfies the builtin error interface
func (e Config_IstioHeadersValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sConfig_IstioHeaders.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = Config_IstioHeadersValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = Config_IstioHeadersValidationError{}

// Validate checks the field values on Config_UpstreamFilterState with the
// rules defined in the proto definition for this message. If any rules are
// violated, the first error encountered is returned, or nil if there are no violations.
func (m *Config_UpstreamFilterState) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on Config_UpstreamFilterState with the
// rules defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// Config_UpstreamFilterStateMultiError, or nil if none found.
func (m *Config_UpstreamFilterState) ValidateAll() error {
	return m.validate(true)
}

func (m *Config_UpstreamFilterState) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	// no validation rules for PeerMetadataKey

	if len(errors) > 0 {
		return Config_UpstreamFilterStateMultiError(errors)
	}

	return nil
}

// Config_UpstreamFilterStateMultiError is an error wrapping multiple
// validation errors returned by Config_UpstreamFilterState.ValidateAll() if
// the designated constraints aren't met.
type Config_UpstreamFilterStateMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m Config_UpstreamFilterStateMultiError) Error() string {
	msgs := make([]string, 0, len(m))
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m Config_UpstreamFilterStateMultiError) AllErrors() []error { return m }

// Config_UpstreamFilterStateValidationError is the validation error returned
// by Config_UpstreamFilterState.Validate if the designated constraints aren't met.
type Config_UpstreamFilterStateValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e Config_UpstreamFilterStateValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e Config_UpstreamFilterStateValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e Config_UpstreamFilterStateValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e Config_UpstreamFilterStateValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e Config_UpstreamFilterStateValidationError) ErrorName() string {
	return "Config_UpstreamFilterStateValidationError"
}

// Error satisfies the builtin error interface
func (e Config_UpstreamFilterStateValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sConfig_UpstreamFilterState.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = Config_UpstreamFilterStateValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = Config_UpstreamFilterStateValidationError{}

// Validate checks the field values on Config_DiscoveryMethod with the rules
// defined in the proto definition for this message. If any rules are
// violated, the first error encountered is returned, or nil if there are no violations.
func (m *Config_DiscoveryMethod) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on Config_DiscoveryMethod with the rules
// defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// Config_DiscoveryMethodMultiError, or nil if none found.
func (m *Config_DiscoveryMethod) ValidateAll() error {
	return m.validate(true)
}

func (m *Config_DiscoveryMethod) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	switch v := m.MethodSpecifier.(type) {
	case *Config_DiscoveryMethod_Baggage:
		if v == nil {
			err := Config_DiscoveryMethodValidationError{
				field:  "MethodSpecifier",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetBaggage()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, Config_DiscoveryMethodValidationError{
						field:  "Baggage",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, Config_DiscoveryMethodValidationError{
						field:  "Baggage",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetBaggage()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return Config_DiscoveryMethodValidationError{
					field:  "Baggage",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *Config_DiscoveryMethod_WorkloadDiscovery:
		if v == nil {
			err := Config_DiscoveryMethodValidationError{
				field:  "MethodSpecifier",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetWorkloadDiscovery()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, Config_DiscoveryMethodValidationError{
						field:  "WorkloadDiscovery",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, Config_DiscoveryMethodValidationError{
						field:  "WorkloadDiscovery",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetWorkloadDiscovery()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return Config_DiscoveryMethodValidationError{
					field:  "WorkloadDiscovery",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *Config_DiscoveryMethod_IstioHeaders:
		if v == nil {
			err := Config_DiscoveryMethodValidationError{
				field:  "MethodSpecifier",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetIstioHeaders()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, Config_DiscoveryMethodValidationError{
						field:  "IstioHeaders",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, Config_DiscoveryMethodValidationError{
						field:  "IstioHeaders",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetIstioHeaders()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return Config_DiscoveryMethodValidationError{
					field:  "IstioHeaders",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *Config_DiscoveryMethod_UpstreamFilterState:
		if v == nil {
			err := Config_DiscoveryMethodValidationError{
				field:  "MethodSpecifier",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetUpstreamFilterState()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, Config_DiscoveryMethodValidationError{
						field:  "UpstreamFilterState",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, Config_DiscoveryMethodValidationError{
						field:  "UpstreamFilterState",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetUpstreamFilterState()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return Config_DiscoveryMethodValidationError{
					field:  "UpstreamFilterState",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	default:
		_ = v // ensures v is used
	}

	if len(errors) > 0 {
		return Config_DiscoveryMethodMultiError(errors)
	}

	return nil
}

// Config_DiscoveryMethodMultiError is an error wrapping multiple validation
// errors returned by Config_DiscoveryMethod.ValidateAll() if the designated
// constraints aren't met.
type Config_DiscoveryMethodMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m Config_DiscoveryMethodMultiError) Error() string {
	msgs := make([]string, 0, len(m))
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m Config_DiscoveryMethodMultiError) AllErrors() []error { return m }

// Config_DiscoveryMethodValidationError is the validation error returned by
// Config_DiscoveryMethod.Validate if the designated constraints aren't met.
type Config_DiscoveryMethodValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e Config_DiscoveryMethodValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e Config_DiscoveryMethodValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e Config_DiscoveryMethodValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e Config_DiscoveryMethodValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e Config_DiscoveryMethodValidationError) ErrorName() string {
	return "Config_DiscoveryMethodValidationError"
}

// Error satisfies the builtin error interface
func (e Config_DiscoveryMethodValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sConfig_DiscoveryMethod.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = Config_DiscoveryMethodValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = Config_DiscoveryMethodValidationError{}

// Validate checks the field values on Config_PropagationMethod with the rules
// defined in the proto definition for this message. If any rules are
// violated, the first error encountered is returned, or nil if there are no violations.
func (m *Config_PropagationMethod) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on Config_PropagationMethod with the
// rules defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// Config_PropagationMethodMultiError, or nil if none found.
func (m *Config_PropagationMethod) ValidateAll() error {
	return m.validate(true)
}

func (m *Config_PropagationMethod) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	switch v := m.MethodSpecifier.(type) {
	case *Config_PropagationMethod_IstioHeaders:
		if v == nil {
			err := Config_PropagationMethodValidationError{
				field:  "MethodSpecifier",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetIstioHeaders()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, Config_PropagationMethodValidationError{
						field:  "IstioHeaders",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, Config_PropagationMethodValidationError{
						field:  "IstioHeaders",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetIstioHeaders()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return Config_PropagationMethodValidationError{
					field:  "IstioHeaders",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *Config_PropagationMethod_Baggage:
		if v == nil {
			err := Config_PropagationMethodValidationError{
				field:  "MethodSpecifier",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

		if all {
			switch v := interface{}(m.GetBaggage()).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, Config_PropagationMethodValidationError{
						field:  "Baggage",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, Config_PropagationMethodValidationError{
						field:  "Baggage",
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			}
		} else if v, ok := interface{}(m.GetBaggage()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return Config_PropagationMethodValidationError{
					field:  "Baggage",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	default:
		_ = v // ensures v is used
	}

	if len(errors) > 0 {
		return Config_PropagationMethodMultiError(errors)
	}

	return nil
}

// Config_PropagationMethodMultiError is an error wrapping multiple validation
// errors returned by Config_PropagationMethod.ValidateAll() if the designated
// constraints aren't met.
type Config_PropagationMethodMultiError []error

// Error returns a concatenation of all the error messages it wraps.
func (m Config_PropagationMethodMultiError) Error() string {
	msgs := make([]string, 0, len(m))
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m Config_PropagationMethodMultiError) AllErrors() []error { return m }

// Config_PropagationMethodValidationError is the validation error returned by
// Config_PropagationMethod.Validate if the designated constraints aren't met.
type Config_PropagationMethodValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e Config_PropagationMethodValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e Config_PropagationMethodValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e Config_PropagationMethodValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e Config_PropagationMethodValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e Config_PropagationMethodValidationError) ErrorName() string {
	return "Config_PropagationMethodValidationError"
}

// Error satisfies the builtin error interface
func (e Config_PropagationMethodValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sConfig_PropagationMethod.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = Config_PropagationMethodValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = Config_PropagationMethodValidationError{}
