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

package spark_authn

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

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

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

	var errors []error

	// no validation rules for Version

	// no validation rules for Timestamp

	// no validation rules for Nonce

	// no validation rules for PublicKey

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m ChallengeMultiError) Error() string {
	msgs := make([]string, 0, len(m))
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m ChallengeMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = ChallengeValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for Version

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

	// no validation rules for ServerHmac

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m ProtectedChallengeMultiError) Error() string {
	msgs := make([]string, 0, len(m))
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m ProtectedChallengeMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = ProtectedChallengeValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for PublicKey

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m GetChallengeRequestMultiError) Error() string {
	msgs := make([]string, 0, len(m))
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m GetChallengeRequestMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = GetChallengeRequestValidationError{}

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

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

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

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

	var errors []error

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

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m GetChallengeResponseMultiError) Error() string {
	msgs := make([]string, 0, len(m))
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m GetChallengeResponseMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = GetChallengeResponseValidationError{}

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

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

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

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

	var errors []error

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

	// no validation rules for Signature

	// no validation rules for PublicKey

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m VerifyChallengeRequestMultiError) Error() string {
	msgs := make([]string, 0, len(m))
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m VerifyChallengeRequestMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = VerifyChallengeRequestValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for SessionToken

	// no validation rules for ExpirationTimestamp

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m VerifyChallengeResponseMultiError) Error() string {
	msgs := make([]string, 0, len(m))
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m VerifyChallengeResponseMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = VerifyChallengeResponseValidationError{}

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