// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: event/api/v1/event.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 MessageProto 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 *MessageProto) Validate() error {
	return m.validate(false)
}

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

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

	var errors []error

	// no validation rules for Key

	// no validation rules for Value

	// no validation rules for Header

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = MessageProtoValidationError{}

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

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

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

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

	var errors []error

	if m.GetMessage() == nil {
		err := HandleEventRequestValidationError{
			field:  "Message",
			reason: "value is required",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = HandleEventRequestValidationError{}

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

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

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

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

	var errors []error

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

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

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

	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = PublishEventRequestValidationError{}

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