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

package idp

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

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

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

	var errors []error

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

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = ConfigValidationError{}

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

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

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

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

	var errors []error

	{
		sorted_keys := make([]string, len(m.GetOpenPlatform()))
		i := 0
		for key := range m.GetOpenPlatform() {
			sorted_keys[i] = key
			i++
		}
		sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] })
		for _, key := range sorted_keys {
			val := m.GetOpenPlatform()[key]
			_ = val

			// no validation rules for OpenPlatform[key]

			if all {
				switch v := interface{}(val).(type) {
				case interface{ ValidateAll() error }:
					if err := v.ValidateAll(); err != nil {
						errors = append(errors, WeChatValidationError{
							field:  fmt.Sprintf("OpenPlatform[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				case interface{ Validate() error }:
					if err := v.Validate(); err != nil {
						errors = append(errors, WeChatValidationError{
							field:  fmt.Sprintf("OpenPlatform[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				}
			} else if v, ok := interface{}(val).(interface{ Validate() error }); ok {
				if err := v.Validate(); err != nil {
					return WeChatValidationError{
						field:  fmt.Sprintf("OpenPlatform[%v]", key),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}

		}
	}

	{
		sorted_keys := make([]string, len(m.GetOfficialAccount()))
		i := 0
		for key := range m.GetOfficialAccount() {
			sorted_keys[i] = key
			i++
		}
		sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] })
		for _, key := range sorted_keys {
			val := m.GetOfficialAccount()[key]
			_ = val

			// no validation rules for OfficialAccount[key]

			if all {
				switch v := interface{}(val).(type) {
				case interface{ ValidateAll() error }:
					if err := v.ValidateAll(); err != nil {
						errors = append(errors, WeChatValidationError{
							field:  fmt.Sprintf("OfficialAccount[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				case interface{ Validate() error }:
					if err := v.Validate(); err != nil {
						errors = append(errors, WeChatValidationError{
							field:  fmt.Sprintf("OfficialAccount[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				}
			} else if v, ok := interface{}(val).(interface{ Validate() error }); ok {
				if err := v.Validate(); err != nil {
					return WeChatValidationError{
						field:  fmt.Sprintf("OfficialAccount[%v]", key),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}

		}
	}

	{
		sorted_keys := make([]string, len(m.GetMiniProgram()))
		i := 0
		for key := range m.GetMiniProgram() {
			sorted_keys[i] = key
			i++
		}
		sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] })
		for _, key := range sorted_keys {
			val := m.GetMiniProgram()[key]
			_ = val

			// no validation rules for MiniProgram[key]

			if all {
				switch v := interface{}(val).(type) {
				case interface{ ValidateAll() error }:
					if err := v.ValidateAll(); err != nil {
						errors = append(errors, WeChatValidationError{
							field:  fmt.Sprintf("MiniProgram[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				case interface{ Validate() error }:
					if err := v.Validate(); err != nil {
						errors = append(errors, WeChatValidationError{
							field:  fmt.Sprintf("MiniProgram[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				}
			} else if v, ok := interface{}(val).(interface{ Validate() error }); ok {
				if err := v.Validate(); err != nil {
					return WeChatValidationError{
						field:  fmt.Sprintf("MiniProgram[%v]", key),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}

		}
	}

	{
		sorted_keys := make([]string, len(m.GetMiniGame()))
		i := 0
		for key := range m.GetMiniGame() {
			sorted_keys[i] = key
			i++
		}
		sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] })
		for _, key := range sorted_keys {
			val := m.GetMiniGame()[key]
			_ = val

			// no validation rules for MiniGame[key]

			if all {
				switch v := interface{}(val).(type) {
				case interface{ ValidateAll() error }:
					if err := v.ValidateAll(); err != nil {
						errors = append(errors, WeChatValidationError{
							field:  fmt.Sprintf("MiniGame[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				case interface{ Validate() error }:
					if err := v.Validate(); err != nil {
						errors = append(errors, WeChatValidationError{
							field:  fmt.Sprintf("MiniGame[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				}
			} else if v, ok := interface{}(val).(interface{ Validate() error }); ok {
				if err := v.Validate(); err != nil {
					return WeChatValidationError{
						field:  fmt.Sprintf("MiniGame[%v]", key),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}

		}
	}

	{
		sorted_keys := make([]string, len(m.GetPay()))
		i := 0
		for key := range m.GetPay() {
			sorted_keys[i] = key
			i++
		}
		sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] })
		for _, key := range sorted_keys {
			val := m.GetPay()[key]
			_ = val

			// no validation rules for Pay[key]

			if all {
				switch v := interface{}(val).(type) {
				case interface{ ValidateAll() error }:
					if err := v.ValidateAll(); err != nil {
						errors = append(errors, WeChatValidationError{
							field:  fmt.Sprintf("Pay[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				case interface{ Validate() error }:
					if err := v.Validate(); err != nil {
						errors = append(errors, WeChatValidationError{
							field:  fmt.Sprintf("Pay[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				}
			} else if v, ok := interface{}(val).(interface{ Validate() error }); ok {
				if err := v.Validate(); err != nil {
					return WeChatValidationError{
						field:  fmt.Sprintf("Pay[%v]", key),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}

		}
	}

	{
		sorted_keys := make([]string, len(m.GetWork()))
		i := 0
		for key := range m.GetWork() {
			sorted_keys[i] = key
			i++
		}
		sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] })
		for _, key := range sorted_keys {
			val := m.GetWork()[key]
			_ = val

			// no validation rules for Work[key]

			if all {
				switch v := interface{}(val).(type) {
				case interface{ ValidateAll() error }:
					if err := v.ValidateAll(); err != nil {
						errors = append(errors, WeChatValidationError{
							field:  fmt.Sprintf("Work[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				case interface{ Validate() error }:
					if err := v.Validate(); err != nil {
						errors = append(errors, WeChatValidationError{
							field:  fmt.Sprintf("Work[%v]", key),
							reason: "embedded message failed validation",
							cause:  err,
						})
					}
				}
			} else if v, ok := interface{}(val).(interface{ Validate() error }); ok {
				if err := v.Validate(); err != nil {
					return WeChatValidationError{
						field:  fmt.Sprintf("Work[%v]", key),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}

		}
	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = WeChatValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for AppId

	// no validation rules for AppSecret

	// no validation rules for Token

	// no validation rules for EncodingAesKey

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = WeChat_OpenPlatformValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for AppId

	// no validation rules for AppSecret

	// no validation rules for Token

	// no validation rules for EncodingAesKey

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = WeChat_OfficialAccountValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for AppId

	// no validation rules for AppSecret

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = WeChat_MiniProgramValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for AppId

	// no validation rules for AppSecret

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = WeChat_MiniGameValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for CorpId

	// no validation rules for CorpSecret

	// no validation rules for AgentId

	// no validation rules for RasPrivateKey

	// no validation rules for Token

	// no validation rules for EncodingAesKey

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = WeChat_WorkValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for AppId

	// no validation rules for Key

	// no validation rules for MchId

	// no validation rules for NotifyUrl

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = WeChat_PayValidationError{}

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