//go:build !disable_pgv
// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: envoy/extensions/matching/actions/transform_stat/v3/transform_stat.proto

package transform_statv3

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

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

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

	var errors []error

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

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

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

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m TransformStatMultiError) 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 TransformStatMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = TransformStatValidationError{}

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

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

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

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

	var errors []error

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m TransformStat_DropStatMultiError) 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 TransformStat_DropStatMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = TransformStat_DropStatValidationError{}

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

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

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

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

	var errors []error

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m TransformStat_DropTagMultiError) 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 TransformStat_DropTagMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = TransformStat_DropTagValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for NewTagValue

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m TransformStat_UpdateTagMultiError) 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 TransformStat_UpdateTagMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = TransformStat_UpdateTagValidationError{}

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