// Code generated by protoc-gen-validate
// source: envoy/data/core/v2alpha/health_check_event.proto
// DO NOT EDIT!!!

package envoy_data_core_v2alpha

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

	"github.com/gogo/protobuf/types"
)

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

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

	if _, ok := HealthCheckerType_name[int32(m.GetHealthCheckerType())]; !ok {
		return HealthCheckEventValidationError{
			Field:  "HealthCheckerType",
			Reason: "value must be one of the defined enum values",
		}
	}

	if v, ok := interface{}(m.GetHost()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return HealthCheckEventValidationError{
				Field:  "Host",
				Reason: "embedded message failed validation",
				Cause:  err,
			}
		}
	}

	if len(m.GetClusterName()) < 1 {
		return HealthCheckEventValidationError{
			Field:  "ClusterName",
			Reason: "value length must be at least 1 bytes",
		}
	}

	switch m.Event.(type) {

	case *HealthCheckEvent_EjectUnhealthyEvent:

		if v, ok := interface{}(m.GetEjectUnhealthyEvent()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return HealthCheckEventValidationError{
					Field:  "EjectUnhealthyEvent",
					Reason: "embedded message failed validation",
					Cause:  err,
				}
			}
		}

	case *HealthCheckEvent_AddHealthyEvent:

		if v, ok := interface{}(m.GetAddHealthyEvent()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return HealthCheckEventValidationError{
					Field:  "AddHealthyEvent",
					Reason: "embedded message failed validation",
					Cause:  err,
				}
			}
		}

	default:
		return HealthCheckEventValidationError{
			Field:  "Event",
			Reason: "value is required",
		}

	}

	return nil
}

// HealthCheckEventValidationError is the validation error returned by
// HealthCheckEvent.Validate if the designated constraints aren't met.
type HealthCheckEventValidationError struct {
	Field  string
	Reason string
	Cause  error
	Key    bool
}

// Error satisfies the builtin error interface
func (e HealthCheckEventValidationError) 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 %sHealthCheckEvent.%s: %s%s",
		key,
		e.Field,
		e.Reason,
		cause)
}

var _ error = HealthCheckEventValidationError{}

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

	if _, ok := HealthCheckFailureType_name[int32(m.GetFailureType())]; !ok {
		return HealthCheckEjectUnhealthyValidationError{
			Field:  "FailureType",
			Reason: "value must be one of the defined enum values",
		}
	}

	return nil
}

// HealthCheckEjectUnhealthyValidationError is the validation error returned by
// HealthCheckEjectUnhealthy.Validate if the designated constraints aren't met.
type HealthCheckEjectUnhealthyValidationError struct {
	Field  string
	Reason string
	Cause  error
	Key    bool
}

// Error satisfies the builtin error interface
func (e HealthCheckEjectUnhealthyValidationError) 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 %sHealthCheckEjectUnhealthy.%s: %s%s",
		key,
		e.Field,
		e.Reason,
		cause)
}

var _ error = HealthCheckEjectUnhealthyValidationError{}

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

	// no validation rules for FirstCheck

	return nil
}

// HealthCheckAddHealthyValidationError is the validation error returned by
// HealthCheckAddHealthy.Validate if the designated constraints aren't met.
type HealthCheckAddHealthyValidationError struct {
	Field  string
	Reason string
	Cause  error
	Key    bool
}

// Error satisfies the builtin error interface
func (e HealthCheckAddHealthyValidationError) 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 %sHealthCheckAddHealthy.%s: %s%s",
		key,
		e.Field,
		e.Reason,
		cause)
}

var _ error = HealthCheckAddHealthyValidationError{}
