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

package blob

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

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

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

	var errors []error

	// no validation rules for Provider

	if utf8.RuneCountInString(m.GetMountPath()) < 1 {
		err := ConfigValidationError{
			field:  "MountPath",
			reason: "value length must be at least 1 runes",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	// no validation rules for PublicUrl

	// no validation rules for InternalUrl

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

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

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = ConfigValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for Region

	// no validation rules for Key

	// no validation rules for Secret

	// no validation rules for Bucket

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = ProviderS3ValidationError{}

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

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

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

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

	var errors []error

	if m.Dir != nil {

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

	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = ProviderOsValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for Id

	// no validation rules for Name

	// no validation rules for Mime

	// no validation rules for Size

	// no validation rules for Url

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

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = BlobFileValidationError{}

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