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

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

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

	var errors []error

	// no validation rules for BizCode

	// no validation rules for Message

	// no validation rules for Domain

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = MetadataValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for Field

	// no validation rules for Order

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = SortFieldValidationError{}

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

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

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

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

	var errors []error

	if m.GetPage() <= 0 {
		err := PaginationRequestValidationError{
			field:  "Page",
			reason: "value must be greater than 0",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if m.GetSize() <= 0 {
		err := PaginationRequestValidationError{
			field:  "Size",
			reason: "value must be greater than 0",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

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

	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = PaginationRequestValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for Page

	// no validation rules for Total

	// no validation rules for Count

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = PaginationResponseValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for Field

	// no validation rules for Value

	// no validation rules for Operator

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = SearchFieldValidationError{}

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

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

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

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

	var errors []error

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

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

	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = SearchRequestValidationError{}

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