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

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

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

	var errors []error

	if m.GetResource() == nil {
		err := RelationshipValidationError{
			field:  "Resource",
			reason: "value is required",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

	if len(m.GetRelation()) > 64 {
		err := RelationshipValidationError{
			field:  "Relation",
			reason: "value length must be at most 64 bytes",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if !_Relationship_Relation_Pattern.MatchString(m.GetRelation()) {
		err := RelationshipValidationError{
			field:  "Relation",
			reason: "value does not match regex pattern \"^[a-z][a-z0-9_]{1,62}[a-z0-9]$\"",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if m.GetSubject() == nil {
		err := RelationshipValidationError{
			field:  "Subject",
			reason: "value is required",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

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

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

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = RelationshipValidationError{}

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

var _Relationship_Relation_Pattern = regexp.MustCompile("^[a-z][a-z0-9_]{1,62}[a-z0-9]$")

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

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

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

	var errors []error

	if len(m.GetCaveatName()) > 128 {
		err := ContextualizedCaveatValidationError{
			field:  "CaveatName",
			reason: "value length must be at most 128 bytes",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if !_ContextualizedCaveat_CaveatName_Pattern.MatchString(m.GetCaveatName()) {
		err := ContextualizedCaveatValidationError{
			field:  "CaveatName",
			reason: "value does not match regex pattern \"^([a-zA-Z0-9_][a-zA-Z0-9/_|-]{0,127})$\"",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = ContextualizedCaveatValidationError{}

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

var _ContextualizedCaveat_CaveatName_Pattern = regexp.MustCompile("^([a-zA-Z0-9_][a-zA-Z0-9/_|-]{0,127})$")

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

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

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

	var errors []error

	if m.GetObject() == nil {
		err := SubjectReferenceValidationError{
			field:  "Object",
			reason: "value is required",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

	if len(m.GetOptionalRelation()) > 64 {
		err := SubjectReferenceValidationError{
			field:  "OptionalRelation",
			reason: "value length must be at most 64 bytes",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if !_SubjectReference_OptionalRelation_Pattern.MatchString(m.GetOptionalRelation()) {
		err := SubjectReferenceValidationError{
			field:  "OptionalRelation",
			reason: "value does not match regex pattern \"^([a-z][a-z0-9_]{1,62}[a-z0-9])?$\"",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = SubjectReferenceValidationError{}

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

var _SubjectReference_OptionalRelation_Pattern = regexp.MustCompile("^([a-z][a-z0-9_]{1,62}[a-z0-9])?$")

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

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

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

	var errors []error

	if len(m.GetObjectType()) > 128 {
		err := ObjectReferenceValidationError{
			field:  "ObjectType",
			reason: "value length must be at most 128 bytes",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if !_ObjectReference_ObjectType_Pattern.MatchString(m.GetObjectType()) {
		err := ObjectReferenceValidationError{
			field:  "ObjectType",
			reason: "value does not match regex pattern \"^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$\"",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if len(m.GetObjectId()) > 1024 {
		err := ObjectReferenceValidationError{
			field:  "ObjectId",
			reason: "value length must be at most 1024 bytes",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if !_ObjectReference_ObjectId_Pattern.MatchString(m.GetObjectId()) {
		err := ObjectReferenceValidationError{
			field:  "ObjectId",
			reason: "value does not match regex pattern \"^(([a-zA-Z0-9/_|\\\\-=+]{1,})|\\\\*)$\"",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = ObjectReferenceValidationError{}

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

var _ObjectReference_ObjectType_Pattern = regexp.MustCompile("^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$")

var _ObjectReference_ObjectId_Pattern = regexp.MustCompile("^(([a-zA-Z0-9/_|\\-=+]{1,})|\\*)$")

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

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

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

	var errors []error

	if len(m.GetToken()) < 1 {
		err := ZedTokenValidationError{
			field:  "Token",
			reason: "value length must be at least 1 bytes",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = ZedTokenValidationError{}

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

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

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

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

	var errors []error

	if l := len(m.GetToken()); l < 1 || l > 102400 {
		err := CursorValidationError{
			field:  "Token",
			reason: "value length must be between 1 and 102400 bytes, inclusive",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = CursorValidationError{}

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

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

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

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

	var errors []error

	if _, ok := _RelationshipUpdate_Operation_NotInLookup[m.GetOperation()]; ok {
		err := RelationshipUpdateValidationError{
			field:  "Operation",
			reason: "value must not be in list [OPERATION_UNSPECIFIED]",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if _, ok := RelationshipUpdate_Operation_name[int32(m.GetOperation())]; !ok {
		err := RelationshipUpdateValidationError{
			field:  "Operation",
			reason: "value must be one of the defined enum values",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if m.GetRelationship() == nil {
		err := RelationshipUpdateValidationError{
			field:  "Relationship",
			reason: "value is required",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = RelationshipUpdateValidationError{}

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

var _RelationshipUpdate_Operation_NotInLookup = map[RelationshipUpdate_Operation]struct{}{
	0: {},
}

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

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

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

	var errors []error

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

	// no validation rules for ExpandedRelation

	oneofTreeTypePresent := false
	switch v := m.TreeType.(type) {
	case *PermissionRelationshipTree_Intermediate:
		if v == nil {
			err := PermissionRelationshipTreeValidationError{
				field:  "TreeType",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}
		oneofTreeTypePresent = true

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

	case *PermissionRelationshipTree_Leaf:
		if v == nil {
			err := PermissionRelationshipTreeValidationError{
				field:  "TreeType",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}
		oneofTreeTypePresent = true

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

	default:
		_ = v // ensures v is used
	}
	if !oneofTreeTypePresent {
		err := PermissionRelationshipTreeValidationError{
			field:  "TreeType",
			reason: "value is required",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = PermissionRelationshipTreeValidationError{}

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

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

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

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

	var errors []error

	if _, ok := _AlgebraicSubjectSet_Operation_NotInLookup[m.GetOperation()]; ok {
		err := AlgebraicSubjectSetValidationError{
			field:  "Operation",
			reason: "value must not be in list [OPERATION_UNSPECIFIED]",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if _, ok := AlgebraicSubjectSet_Operation_name[int32(m.GetOperation())]; !ok {
		err := AlgebraicSubjectSetValidationError{
			field:  "Operation",
			reason: "value must be one of the defined enum values",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

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

		if item == nil {
			err := AlgebraicSubjectSetValidationError{
				field:  fmt.Sprintf("Children[%v]", idx),
				reason: "value is required",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

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

	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = AlgebraicSubjectSetValidationError{}

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

var _AlgebraicSubjectSet_Operation_NotInLookup = map[AlgebraicSubjectSet_Operation]struct{}{
	0: {},
}

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

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

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

	var errors []error

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

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

	}

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = DirectSubjectSetValidationError{}

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

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

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

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

	var errors []error

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

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

	return nil
}

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

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

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

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

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

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

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

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

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

var _ error = PartialCaveatInfoValidationError{}

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