// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: service/data/base.proto

package data

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

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

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

	var errors []error

	// no validation rules for Price

	// no validation rules for Timestamp

	// no validation rules for SourceToken

	// no validation rules for TargetToken

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = DefiPriceItemValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for Number

	// no validation rules for Hash

	// no validation rules for ParentHash

	// no validation rules for Timestamp

	// no validation rules for Difficulty

	// no validation rules for ExtraData

	// no validation rules for GasLimit

	// no validation rules for GasUsed

	// no validation rules for BaseFeePerGas

	// no validation rules for Miner

	// no validation rules for MixHash

	// no validation rules for Nonce

	// no validation rules for ReceiptsRoot

	// no validation rules for Sha3Uncles

	// no validation rules for Size

	// no validation rules for StateRoot

	// no validation rules for TransactionsRoot

	// no validation rules for TransactionsCount

	// no validation rules for UnclesCount

	// no validation rules for ChainId

	// no validation rules for ChainUniqueId

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

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

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = BlockItemValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for Type

	// no validation rules for Status

	// no validation rules for BlockHash

	// no validation rules for BlockNumber

	// no validation rules for BlockTimestamp

	// no validation rules for TransactionHash

	// no validation rules for TransactionIndex

	// no validation rules for FromAddress

	// no validation rules for ToAddress

	// no validation rules for Value

	// no validation rules for Input

	// no validation rules for Nonce

	// no validation rules for ContractAddress

	// no validation rules for Gas

	// no validation rules for GasPrice

	// no validation rules for GasUsed

	// no validation rules for EffectiveGasPrice

	// no validation rules for CumulativeGasUsed

	// no validation rules for MaxFeePerGas

	// no validation rules for MaxPriorityFeePerGas

	// no validation rules for LogsCount

	// no validation rules for R

	// no validation rules for S

	// no validation rules for V

	// no validation rules for ChainId

	// no validation rules for ChainUniqueId

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

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

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = TransactionItemValidationError{}

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