// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: authzed/api/v1/permission_service.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 Consistency with the rules defined in
// the proto definition for this message. If any rules are violated, an error
// is returned.
func (m *Consistency) Validate() error {
	if m == nil {
		return nil
	}

	switch m.Requirement.(type) {

	case *Consistency_MinimizeLatency:

		if m.GetMinimizeLatency() != true {
			return ConsistencyValidationError{
				field:  "MinimizeLatency",
				reason: "value must equal true",
			}
		}

	case *Consistency_AtLeastAsFresh:

		if v, ok := interface{}(m.GetAtLeastAsFresh()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return ConsistencyValidationError{
					field:  "AtLeastAsFresh",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *Consistency_AtExactSnapshot:

		if v, ok := interface{}(m.GetAtExactSnapshot()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return ConsistencyValidationError{
					field:  "AtExactSnapshot",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	case *Consistency_FullyConsistent:

		if m.GetFullyConsistent() != true {
			return ConsistencyValidationError{
				field:  "FullyConsistent",
				reason: "value must equal true",
			}
		}

	default:
		return ConsistencyValidationError{
			field:  "Requirement",
			reason: "value is required",
		}

	}

	return nil
}

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

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

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

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

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

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

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

var _ error = ConsistencyValidationError{}

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

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

	if len(m.GetResourceType()) > 128 {
		return RelationshipFilterValidationError{
			field:  "ResourceType",
			reason: "value length must be at most 128 bytes",
		}
	}

	if !_RelationshipFilter_ResourceType_Pattern.MatchString(m.GetResourceType()) {
		return RelationshipFilterValidationError{
			field:  "ResourceType",
			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.GetOptionalResourceId()) > 128 {
		return RelationshipFilterValidationError{
			field:  "OptionalResourceId",
			reason: "value length must be at most 128 bytes",
		}
	}

	if !_RelationshipFilter_OptionalResourceId_Pattern.MatchString(m.GetOptionalResourceId()) {
		return RelationshipFilterValidationError{
			field:  "OptionalResourceId",
			reason: "value does not match regex pattern \"^([a-zA-Z0-9_][a-zA-Z0-9/_-]{0,127})?$\"",
		}
	}

	if len(m.GetOptionalRelation()) > 64 {
		return RelationshipFilterValidationError{
			field:  "OptionalRelation",
			reason: "value length must be at most 64 bytes",
		}
	}

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

	if v, ok := interface{}(m.GetOptionalSubjectFilter()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return RelationshipFilterValidationError{
				field:  "OptionalSubjectFilter",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	return nil
}

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

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

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

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

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

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

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

var _ error = RelationshipFilterValidationError{}

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

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

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

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

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

	if len(m.GetSubjectType()) > 128 {
		return SubjectFilterValidationError{
			field:  "SubjectType",
			reason: "value length must be at most 128 bytes",
		}
	}

	if !_SubjectFilter_SubjectType_Pattern.MatchString(m.GetSubjectType()) {
		return SubjectFilterValidationError{
			field:  "SubjectType",
			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.GetOptionalSubjectId()) > 128 {
		return SubjectFilterValidationError{
			field:  "OptionalSubjectId",
			reason: "value length must be at most 128 bytes",
		}
	}

	if !_SubjectFilter_OptionalSubjectId_Pattern.MatchString(m.GetOptionalSubjectId()) {
		return SubjectFilterValidationError{
			field:  "OptionalSubjectId",
			reason: "value does not match regex pattern \"^([a-zA-Z0-9_][a-zA-Z0-9/_-]{0,127})?$\"",
		}
	}

	if v, ok := interface{}(m.GetOptionalRelation()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return SubjectFilterValidationError{
				field:  "OptionalRelation",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	return nil
}

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

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

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

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

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

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

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

var _ error = SubjectFilterValidationError{}

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

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

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

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

	if v, ok := interface{}(m.GetConsistency()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return ReadRelationshipsRequestValidationError{
				field:  "Consistency",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	if m.GetRelationshipFilter() == nil {
		return ReadRelationshipsRequestValidationError{
			field:  "RelationshipFilter",
			reason: "value is required",
		}
	}

	if v, ok := interface{}(m.GetRelationshipFilter()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return ReadRelationshipsRequestValidationError{
				field:  "RelationshipFilter",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	return nil
}

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

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

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

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

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

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

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

var _ error = ReadRelationshipsRequestValidationError{}

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

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

	if v, ok := interface{}(m.GetReadAt()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return ReadRelationshipsResponseValidationError{
				field:  "ReadAt",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	if v, ok := interface{}(m.GetRelationship()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return ReadRelationshipsResponseValidationError{
				field:  "Relationship",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	return nil
}

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

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

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

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

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

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

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

var _ error = ReadRelationshipsResponseValidationError{}

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

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

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

	if m.GetFilter() == nil {
		return PreconditionValidationError{
			field:  "Filter",
			reason: "value is required",
		}
	}

	if v, ok := interface{}(m.GetFilter()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return PreconditionValidationError{
				field:  "Filter",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	return nil
}

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

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

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

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

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

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

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

var _ error = PreconditionValidationError{}

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

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

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

		if item == nil {
			return WriteRelationshipsRequestValidationError{
				field:  fmt.Sprintf("Updates[%v]", idx),
				reason: "value is required",
			}
		}

		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return WriteRelationshipsRequestValidationError{
					field:  fmt.Sprintf("Updates[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

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

		if item == nil {
			return WriteRelationshipsRequestValidationError{
				field:  fmt.Sprintf("OptionalPreconditions[%v]", idx),
				reason: "value is required",
			}
		}

		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return WriteRelationshipsRequestValidationError{
					field:  fmt.Sprintf("OptionalPreconditions[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

	return nil
}

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

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

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

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

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

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

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

var _ error = WriteRelationshipsRequestValidationError{}

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

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

	if v, ok := interface{}(m.GetWrittenAt()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return WriteRelationshipsResponseValidationError{
				field:  "WrittenAt",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	return nil
}

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

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

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

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

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

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

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

var _ error = WriteRelationshipsResponseValidationError{}

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

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

	if m.GetRelationshipFilter() == nil {
		return DeleteRelationshipsRequestValidationError{
			field:  "RelationshipFilter",
			reason: "value is required",
		}
	}

	if v, ok := interface{}(m.GetRelationshipFilter()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return DeleteRelationshipsRequestValidationError{
				field:  "RelationshipFilter",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

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

		if item == nil {
			return DeleteRelationshipsRequestValidationError{
				field:  fmt.Sprintf("OptionalPreconditions[%v]", idx),
				reason: "value is required",
			}
		}

		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return DeleteRelationshipsRequestValidationError{
					field:  fmt.Sprintf("OptionalPreconditions[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

	return nil
}

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

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

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

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

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

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

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

var _ error = DeleteRelationshipsRequestValidationError{}

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

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

	if v, ok := interface{}(m.GetDeletedAt()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return DeleteRelationshipsResponseValidationError{
				field:  "DeletedAt",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	return nil
}

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

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

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

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

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

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

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

var _ error = DeleteRelationshipsResponseValidationError{}

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

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

	if v, ok := interface{}(m.GetConsistency()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return CheckPermissionRequestValidationError{
				field:  "Consistency",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

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

	if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return CheckPermissionRequestValidationError{
				field:  "Resource",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	if len(m.GetPermission()) > 64 {
		return CheckPermissionRequestValidationError{
			field:  "Permission",
			reason: "value length must be at most 64 bytes",
		}
	}

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

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

	if v, ok := interface{}(m.GetSubject()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return CheckPermissionRequestValidationError{
				field:  "Subject",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	return nil
}

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

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

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

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

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

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

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

var _ error = CheckPermissionRequestValidationError{}

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

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

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

	if v, ok := interface{}(m.GetCheckedAt()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return CheckPermissionResponseValidationError{
				field:  "CheckedAt",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	// no validation rules for Permissionship

	return nil
}

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

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

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

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

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

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

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

var _ error = CheckPermissionResponseValidationError{}

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

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

	if v, ok := interface{}(m.GetConsistency()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return ExpandPermissionTreeRequestValidationError{
				field:  "Consistency",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

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

	if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return ExpandPermissionTreeRequestValidationError{
				field:  "Resource",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	if len(m.GetPermission()) > 64 {
		return ExpandPermissionTreeRequestValidationError{
			field:  "Permission",
			reason: "value length must be at most 64 bytes",
		}
	}

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

	return nil
}

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

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

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

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

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

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

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

var _ error = ExpandPermissionTreeRequestValidationError{}

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

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

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

	if v, ok := interface{}(m.GetExpandedAt()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return ExpandPermissionTreeResponseValidationError{
				field:  "ExpandedAt",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	if v, ok := interface{}(m.GetTreeRoot()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return ExpandPermissionTreeResponseValidationError{
				field:  "TreeRoot",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	return nil
}

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

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

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

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

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

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

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

var _ error = ExpandPermissionTreeResponseValidationError{}

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

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

	if v, ok := interface{}(m.GetConsistency()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return LookupResourcesRequestValidationError{
				field:  "Consistency",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	if len(m.GetResourceObjectType()) > 128 {
		return LookupResourcesRequestValidationError{
			field:  "ResourceObjectType",
			reason: "value length must be at most 128 bytes",
		}
	}

	if !_LookupResourcesRequest_ResourceObjectType_Pattern.MatchString(m.GetResourceObjectType()) {
		return LookupResourcesRequestValidationError{
			field:  "ResourceObjectType",
			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.GetPermission()) > 64 {
		return LookupResourcesRequestValidationError{
			field:  "Permission",
			reason: "value length must be at most 64 bytes",
		}
	}

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

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

	if v, ok := interface{}(m.GetSubject()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return LookupResourcesRequestValidationError{
				field:  "Subject",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	return nil
}

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

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

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

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

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

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

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

var _ error = LookupResourcesRequestValidationError{}

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

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

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

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

	if v, ok := interface{}(m.GetLookedUpAt()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return LookupResourcesResponseValidationError{
				field:  "LookedUpAt",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	// no validation rules for ResourceObjectId

	return nil
}

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

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

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

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

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

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

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

var _ error = LookupResourcesResponseValidationError{}

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

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

	if len(m.GetRelation()) > 64 {
		return SubjectFilter_RelationFilterValidationError{
			field:  "Relation",
			reason: "value length must be at most 64 bytes",
		}
	}

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

	return nil
}

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

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

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

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

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

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

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

var _ error = SubjectFilter_RelationFilterValidationError{}

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

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