// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: payment/api/checkout/v1/checkout.proto

package v1

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

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

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

	var errors []error

	if _, ok := _CheckoutNowRequest_Provider_InLookup[m.GetProvider()]; !ok {
		err := CheckoutNowRequestValidationError{
			field:  "Provider",
			reason: "value must be in list [stripe]",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	// no validation rules for CurrencyCode

	if len(m.GetItems()) < 1 {
		err := CheckoutNowRequestValidationError{
			field:  "Items",
			reason: "value must contain at least 1 item(s)",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

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

	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = CheckoutNowRequestValidationError{}

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

var _CheckoutNowRequest_Provider_InLookup = map[string]struct{}{
	"stripe": {},
}

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

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

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

	var errors []error

	// no validation rules for Id

	// no validation rules for PriceId

	// no validation rules for Quantity

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

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = CheckoutItemParamsValidationError{}

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

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

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

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

	var errors []error

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

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

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = CheckoutNowReplyValidationError{}

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

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

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

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

	var errors []error

	if utf8.RuneCountInString(m.GetOrderId()) < 1 {
		err := CheckOutOrderRequestValidationError{
			field:  "OrderId",
			reason: "value length must be at least 1 runes",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if _, ok := _CheckOutOrderRequest_Provider_InLookup[m.GetProvider()]; !ok {
		err := CheckOutOrderRequestValidationError{
			field:  "Provider",
			reason: "value must be in list [stripe]",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	// no validation rules for CurrencyCode

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = CheckOutOrderRequestValidationError{}

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

var _CheckOutOrderRequest_Provider_InLookup = map[string]struct{}{
	"stripe": {},
}

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

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

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

	var errors []error

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

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = CheckoutOrderReplyValidationError{}

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