// 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"
	"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{}
)

// Validate checks the field values on Relationship with the rules defined in
// the proto definition for this message. If any rules are violated, an error
// is returned.
func (m *Relationship) Validate() error {
	if m == nil {
		return nil
	}

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

	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 {
		return RelationshipValidationError{
			field:  "Relation",
			reason: "value length must be at most 64 bytes",
		}
	}

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

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

	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,
			}
		}
	}

	return nil
}

// 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_]{2,62}[a-z0-9]$")

// Validate checks the field values on SubjectReference with the rules defined
// in the proto definition for this message. If any rules are violated, an
// error is returned.
func (m *SubjectReference) Validate() error {
	if m == nil {
		return nil
	}

	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 {
		return SubjectReferenceValidationError{
			field:  "OptionalRelation",
			reason: "value length must be at most 64 bytes",
		}
	}

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

	return nil
}

// 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_]{2,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, an
// error is returned.
func (m *ObjectReference) Validate() error {
	if m == nil {
		return nil
	}

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

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

	if len(m.GetObjectId()) > 128 {
		return ObjectReferenceValidationError{
			field:  "ObjectId",
			reason: "value length must be at most 128 bytes",
		}
	}

	if !_ObjectReference_ObjectId_Pattern.MatchString(m.GetObjectId()) {
		return ObjectReferenceValidationError{
			field:  "ObjectId",
			reason: "value does not match regex pattern \"^[a-zA-Z0-9_][a-zA-Z0-9/_-]{0,127}$\"",
		}
	}

	return nil
}

// 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_]{2,61}[a-z0-9]/)?[a-z][a-z0-9_]{2,62}[a-z0-9]$")

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

// Validate checks the field values on ZedToken with the rules defined in the
// proto definition for this message. If any rules are violated, an error is returned.
func (m *ZedToken) Validate() error {
	if m == nil {
		return nil
	}

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

	return nil
}

// 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 RelationshipUpdate with the rules
// defined in the proto definition for this message. If any rules are
// violated, an error is returned.
func (m *RelationshipUpdate) Validate() error {
	if m == nil {
		return nil
	}

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

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

	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,
			}
		}
	}

	return nil
}

// 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{}

// Validate checks the field values on PermissionRelationshipTree with the
// rules defined in the proto definition for this message. If any rules are
// violated, an error is returned.
func (m *PermissionRelationshipTree) Validate() error {
	if m == nil {
		return nil
	}

	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

	switch m.TreeType.(type) {

	case *PermissionRelationshipTree_Intermediate:

		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, 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:
		return PermissionRelationshipTreeValidationError{
			field:  "TreeType",
			reason: "value is required",
		}

	}

	return nil
}

// 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, an error is returned.
func (m *AlgebraicSubjectSet) Validate() error {
	if m == nil {
		return nil
	}

	// no validation rules for Operation

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

		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,
				}
			}
		}

	}

	return nil
}

// 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{}

// Validate checks the field values on DirectSubjectSet with the rules defined
// in the proto definition for this message. If any rules are violated, an
// error is returned.
func (m *DirectSubjectSet) Validate() error {
	if m == nil {
		return nil
	}

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

		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,
				}
			}
		}

	}

	return nil
}

// 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{}
