// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: envoy/extensions/filters/common/dependency/v3/dependency.proto

package dependencyv3

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 Dependency 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 *Dependency) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on Dependency 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 DependencyMultiError, or
// nil if none found.
func (m *Dependency) ValidateAll() error {
	return m.validate(true)
}

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

	var errors []error

	// no validation rules for Type

	if utf8.RuneCountInString(m.GetName()) < 1 {
		err := DependencyValidationError{
			field:  "Name",
			reason: "value length must be at least 1 runes",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

// Error satisfies the builtin error interface
func (e DependencyValidationError) 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 %sDependency.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = DependencyValidationError{}

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

// Validate checks the field values on FilterDependencies 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 *FilterDependencies) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on FilterDependencies 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
// FilterDependenciesMultiError, or nil if none found.
func (m *FilterDependencies) ValidateAll() error {
	return m.validate(true)
}

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

	var errors []error

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

		if all {
			switch v := interface{}(item).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, FilterDependenciesValidationError{
						field:  fmt.Sprintf("DecodeRequired[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, FilterDependenciesValidationError{
						field:  fmt.Sprintf("DecodeRequired[%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 FilterDependenciesValidationError{
					field:  fmt.Sprintf("DecodeRequired[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

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

		if all {
			switch v := interface{}(item).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, FilterDependenciesValidationError{
						field:  fmt.Sprintf("DecodeProvided[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, FilterDependenciesValidationError{
						field:  fmt.Sprintf("DecodeProvided[%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 FilterDependenciesValidationError{
					field:  fmt.Sprintf("DecodeProvided[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

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

		if all {
			switch v := interface{}(item).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, FilterDependenciesValidationError{
						field:  fmt.Sprintf("EncodeRequired[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, FilterDependenciesValidationError{
						field:  fmt.Sprintf("EncodeRequired[%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 FilterDependenciesValidationError{
					field:  fmt.Sprintf("EncodeRequired[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

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

		if all {
			switch v := interface{}(item).(type) {
			case interface{ ValidateAll() error }:
				if err := v.ValidateAll(); err != nil {
					errors = append(errors, FilterDependenciesValidationError{
						field:  fmt.Sprintf("EncodeProvided[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					})
				}
			case interface{ Validate() error }:
				if err := v.Validate(); err != nil {
					errors = append(errors, FilterDependenciesValidationError{
						field:  fmt.Sprintf("EncodeProvided[%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 FilterDependenciesValidationError{
					field:  fmt.Sprintf("EncodeProvided[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

// Error satisfies the builtin error interface
func (e FilterDependenciesValidationError) 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 %sFilterDependencies.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = FilterDependenciesValidationError{}

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

// Validate checks the field values on MatchingRequirements 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 *MatchingRequirements) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on MatchingRequirements 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
// MatchingRequirementsMultiError, or nil if none found.
func (m *MatchingRequirements) ValidateAll() error {
	return m.validate(true)
}

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

	var errors []error

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

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

	return nil
}

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

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

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

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

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

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

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

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

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

// Error satisfies the builtin error interface
func (e MatchingRequirementsValidationError) 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 %sMatchingRequirements.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = MatchingRequirementsValidationError{}

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

// Validate checks the field values on MatchingRequirements_DataInputAllowList
// 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 *MatchingRequirements_DataInputAllowList) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on
// MatchingRequirements_DataInputAllowList 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
// MatchingRequirements_DataInputAllowListMultiError, or nil if none found.
func (m *MatchingRequirements_DataInputAllowList) ValidateAll() error {
	return m.validate(true)
}

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

	var errors []error

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

	return nil
}

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

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

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

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

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

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

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

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

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

// Error satisfies the builtin error interface
func (e MatchingRequirements_DataInputAllowListValidationError) 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 %sMatchingRequirements_DataInputAllowList.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = MatchingRequirements_DataInputAllowListValidationError{}

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