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

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

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

	var errors []error

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m GetCurrentPermissionRequestMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m GetCurrentPermissionRequestMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = GetCurrentPermissionRequestValidationError{}

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

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

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

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

	var errors []error

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

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

	}

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m GetCurrentPermissionReplyMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m GetCurrentPermissionReplyMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = GetCurrentPermissionReplyValidationError{}

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

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

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

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

	var errors []error

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

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

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

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m CheckPermissionRequestMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m CheckPermissionRequestMultiError) AllErrors() []error { return m }

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

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

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

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

	var errors []error

	// no validation rules for Effect

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m CheckPermissionReplyMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m CheckPermissionReplyMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = CheckPermissionReplyValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for Namespace

	// no validation rules for Resource

	// no validation rules for Action

	// no validation rules for Subject

	// no validation rules for Effect

	// no validation rules for TenantId

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m PermissionMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m PermissionMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = PermissionValidationError{}

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

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

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

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

	var errors []error

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

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

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

	}

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m UpdateSubjectPermissionRequestMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m UpdateSubjectPermissionRequestMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = UpdateSubjectPermissionRequestValidationError{}

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

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

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

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

	var errors []error

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

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

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

	// no validation rules for Effect

	// no validation rules for TenantId

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m UpdateSubjectPermissionAclMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m UpdateSubjectPermissionAclMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = UpdateSubjectPermissionAclValidationError{}

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

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

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

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

	var errors []error

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

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

	}

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m UpdateSubjectPermissionResponseMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m UpdateSubjectPermissionResponseMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = UpdateSubjectPermissionResponseValidationError{}

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

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

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

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

	var errors []error

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

	if m.Namespace != nil {
		// no validation rules for Namespace
	}

	if m.Resource != nil {
		// no validation rules for Resource
	}

	if m.Action != nil {
		// no validation rules for Action
	}

	if m.TenantId != nil {
		// no validation rules for TenantId
	}

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m RemoveSubjectPermissionRequestMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m RemoveSubjectPermissionRequestMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = RemoveSubjectPermissionRequestValidationError{}

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

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

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

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

	var errors []error

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m RemoveSubjectPermissionReplyMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m RemoveSubjectPermissionReplyMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = RemoveSubjectPermissionReplyValidationError{}

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

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

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

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

	var errors []error

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

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

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

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

	if _, ok := _AddSubjectPermissionRequest_Effect_InLookup[m.GetEffect()]; !ok {
		err := AddSubjectPermissionRequestValidationError{
			field:  "Effect",
			reason: "value must be in list [GRANT FORBIDDEN]",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	// no validation rules for TenantId

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m AddSubjectPermissionRequestMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m AddSubjectPermissionRequestMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = AddSubjectPermissionRequestValidationError{}

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

var _AddSubjectPermissionRequest_Effect_InLookup = map[Effect]struct{}{
	1: {},
	2: {},
}

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

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

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

	var errors []error

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m AddSubjectPermissionResponseMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m AddSubjectPermissionResponseMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = AddSubjectPermissionResponseValidationError{}

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

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

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

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

	var errors []error

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m ListSubjectPermissionRequestMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m ListSubjectPermissionRequestMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = ListSubjectPermissionRequestValidationError{}

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

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

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

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

	var errors []error

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

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

	}

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

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

	}

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m ListSubjectPermissionResponseMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m ListSubjectPermissionResponseMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = ListSubjectPermissionResponseValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for DisplayName

	// no validation rules for Side

	// no validation rules for Priority

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

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

	}

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

	// no validation rules for Name

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m PermissionDefGroupMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m PermissionDefGroupMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = PermissionDefGroupValidationError{}

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

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

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

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

	var errors []error

	// no validation rules for DisplayName

	// no validation rules for Side

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

	// no validation rules for Namespace

	// no validation rules for Action

	// no validation rules for Granted

	// no validation rules for Name

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m PermissionDefMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m PermissionDefMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = PermissionDefValidationError{}

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

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

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

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

	var errors []error

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

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

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

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

	return nil
}

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

// Error returns a concatenation of all the error messages it wraps.
func (m PermissionRequirementMultiError) Error() string {
	var msgs []string
	for _, err := range m {
		msgs = append(msgs, err.Error())
	}
	return strings.Join(msgs, "; ")
}

// AllErrors returns a list of validation violation errors.
func (m PermissionRequirementMultiError) AllErrors() []error { return m }

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

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

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

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

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

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

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

var _ error = PermissionRequirementValidationError{}

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