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

package detectorspb

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

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

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

	var errors []error

	// no validation rules for SourceId

	// no validation rules for Redacted

	// no validation rules for Verified

	// no validation rules for Hash

	// no validation rules for ExtraData

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

	// no validation rules for HashV2

	// no validation rules for DecoderType

	// no validation rules for VerificationErrorMessage

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

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = ResultValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for WordMatch

	// no validation rules for LowEntropy

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = FalsePositiveInfoValidationError{}

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

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

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

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

	var errors []error

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

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

	}

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

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

	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = StructuredDataValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for CertificateFingerprint

	// no validation rules for VerificationUrl

	// no validation rules for ExpirationTimestamp

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = TlsPrivateKeyValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for User

	// no validation rules for PublicKeyFingerprint

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = GitHubSSHKeyValidationError{}

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