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

package proto

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

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

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

	var errors []error

	if m.GetRaw() == nil {
		err := AddTxnReqValidationError{
			field:  "Raw",
			reason: "value is required",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if a := m.GetRaw(); a != nil {

	}

	if m.GetFrom() != "" {

		if !_AddTxnReq_From_Pattern.MatchString(m.GetFrom()) {
			err := AddTxnReqValidationError{
				field:  "From",
				reason: "value does not match regex pattern \"^0x[a-fA-F0-9]{40}$\"",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = AddTxnReqValidationError{}

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

var _AddTxnReq_From_Pattern = regexp.MustCompile("^0x[a-fA-F0-9]{40}$")

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

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

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

	var errors []error

	// no validation rules for TxHash

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = AddTxnRespValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for Length

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = TxnPoolStatusRespValidationError{}

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

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

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

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

	var errors []error

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

	_SubscribeRequest_Types_Unique := make(map[EventType]struct{}, len(m.GetTypes()))

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

		if _, exists := _SubscribeRequest_Types_Unique[item]; exists {
			err := SubscribeRequestValidationError{
				field:  fmt.Sprintf("Types[%v]", idx),
				reason: "repeated value must contain unique items",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		} else {
			_SubscribeRequest_Types_Unique[item] = struct{}{}
		}

		if _, ok := EventType_name[int32(item)]; !ok {
			err := SubscribeRequestValidationError{
				field:  fmt.Sprintf("Types[%v]", idx),
				reason: "value must be one of the defined enum values",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = SubscribeRequestValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for Type

	// no validation rules for TxHash

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = TxPoolEventValidationError{}

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