// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: user/private/biz/cache.proto

package biz

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

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

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

	var errors []error

	// no validation rules for UserId

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = ForgetPasswordTwoStepTokenPayloadValidationError{}

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

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

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

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

	var errors []error

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

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

	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = UserRoleCacheItemValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for AppId

	// no validation rules for SessionKey

	// no validation rules for OpenId

	// no validation rules for UnionId

	// no validation rules for Step

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = WeChatMiniProgramLoginTwoStepTokenPayloadValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for RoleId

	// no validation rules for TenantId

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = UserRoleCacheItem_UserRoleValidationError{}

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