// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: rpc/cluster_ops.proto

package rpc

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

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

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

	var errors []error

	// no validation rules for OrgId

	// no validation rules for ProjectId

	// no validation rules for ClusterId

	if m.TidbPool != nil {
		// no validation rules for TidbPool
	}

	if m.RuMode != nil {
		// no validation rules for RuMode
	}

	if m.MinTidbReplicas != nil {
		// no validation rules for MinTidbReplicas
	}

	if m.MaxTidbReplicas != nil {
		// no validation rules for MaxTidbReplicas
	}

	if m.MinRcu != nil {
		// no validation rules for MinRcu
	}

	if m.MaxRcu != nil {
		// no validation rules for MaxRcu
	}

	if m.Canary != nil {
		// no validation rules for Canary
	}

	if m.EnableCustomerAlert != nil {
		// no validation rules for EnableCustomerAlert
	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = UpdateClusterRequestValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for OrgId

	// no validation rules for ProjectId

	// no validation rules for ClusterId

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = GetClusterRequestValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for OrgId

	// no validation rules for ProjectId

	// no validation rules for ClusterId

	// no validation rules for KeyspaceToken

	// no validation rules for KeyspaceId

	// no validation rules for Kubernetes

	// no validation rules for Provider

	// no validation rules for TidbPool

	// no validation rules for RuMode

	// no validation rules for MinRcu

	// no validation rules for MaxRcu

	// no validation rules for EnhancedEncryptionEnabled

	// no validation rules for ZoneRedundantEnabled

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

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

	}

	// no validation rules for ClusterPlan

	// no validation rules for EnableCustomerAlert

	if m.MinTidbReplicas != nil {
		// no validation rules for MinTidbReplicas
	}

	if m.MaxTidbReplicas != nil {
		// no validation rules for MaxTidbReplicas
	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = ClusterDetailsValidationError{}

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