// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: envoy/type/tracing/v2/custom_tag.proto

package envoy_type_tracing_v2

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

	"github.com/golang/protobuf/ptypes"
)

// 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)
	_ = ptypes.DynamicAny{}
)

// define the regex for a UUID once up-front
var _custom_tag_uuidPattern = regexp.MustCompile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")

// Validate checks the field values on CustomTag with the rules defined in the
// proto definition for this message. If any rules are violated, an error is returned.
func (m *CustomTag) Validate() error {
	if m == nil {
		return nil
	}

	if len(m.GetTag()) < 1 {
		return CustomTagValidationError{
			field:  "Tag",
			reason: "value length must be at least 1 bytes",
		}
	}

	switch m.Type.(type) {

	case *CustomTag_Literal_:

		if v, ok := interface{}(m.GetLiteral()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return CustomTagValidationError{
					field:  "Literal",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *CustomTag_Environment_:

		if v, ok := interface{}(m.GetEnvironment()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return CustomTagValidationError{
					field:  "Environment",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *CustomTag_RequestHeader:

		if v, ok := interface{}(m.GetRequestHeader()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return CustomTagValidationError{
					field:  "RequestHeader",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *CustomTag_Metadata_:

		if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return CustomTagValidationError{
					field:  "Metadata",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	default:
		return CustomTagValidationError{
			field:  "Type",
			reason: "value is required",
		}

	}

	return nil
}

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

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

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

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

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

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

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

var _ error = CustomTagValidationError{}

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

// Validate checks the field values on CustomTag_Literal with the rules defined
// in the proto definition for this message. If any rules are violated, an
// error is returned.
func (m *CustomTag_Literal) Validate() error {
	if m == nil {
		return nil
	}

	if len(m.GetValue()) < 1 {
		return CustomTag_LiteralValidationError{
			field:  "Value",
			reason: "value length must be at least 1 bytes",
		}
	}

	return nil
}

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

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

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

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

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

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

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

var _ error = CustomTag_LiteralValidationError{}

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

// Validate checks the field values on CustomTag_Environment with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned.
func (m *CustomTag_Environment) Validate() error {
	if m == nil {
		return nil
	}

	if len(m.GetName()) < 1 {
		return CustomTag_EnvironmentValidationError{
			field:  "Name",
			reason: "value length must be at least 1 bytes",
		}
	}

	// no validation rules for DefaultValue

	return nil
}

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

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

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

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

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

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

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

var _ error = CustomTag_EnvironmentValidationError{}

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

// Validate checks the field values on CustomTag_Header with the rules defined
// in the proto definition for this message. If any rules are violated, an
// error is returned.
func (m *CustomTag_Header) Validate() error {
	if m == nil {
		return nil
	}

	if len(m.GetName()) < 1 {
		return CustomTag_HeaderValidationError{
			field:  "Name",
			reason: "value length must be at least 1 bytes",
		}
	}

	// no validation rules for DefaultValue

	return nil
}

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

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

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

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

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

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

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

var _ error = CustomTag_HeaderValidationError{}

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

// Validate checks the field values on CustomTag_Metadata with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned.
func (m *CustomTag_Metadata) Validate() error {
	if m == nil {
		return nil
	}

	if v, ok := interface{}(m.GetKind()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return CustomTag_MetadataValidationError{
				field:  "Kind",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	if v, ok := interface{}(m.GetMetadataKey()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return CustomTag_MetadataValidationError{
				field:  "MetadataKey",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	// no validation rules for DefaultValue

	return nil
}

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

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

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

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

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

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

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

var _ error = CustomTag_MetadataValidationError{}

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