...

Source file src/github.com/emissary-ingress/emissary/v3/pkg/api/envoy/config/rbac/v2/rbac.pb.validate.go

Documentation: github.com/emissary-ingress/emissary/v3/pkg/api/envoy/config/rbac/v2

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/config/rbac/v2/rbac.proto
     3  
     4  package rbacv2
     5  
     6  import (
     7  	"bytes"
     8  	"errors"
     9  	"fmt"
    10  	"net"
    11  	"net/mail"
    12  	"net/url"
    13  	"regexp"
    14  	"sort"
    15  	"strings"
    16  	"time"
    17  	"unicode/utf8"
    18  
    19  	"google.golang.org/protobuf/types/known/anypb"
    20  )
    21  
    22  // ensure the imports are used
    23  var (
    24  	_ = bytes.MinRead
    25  	_ = errors.New("")
    26  	_ = fmt.Print
    27  	_ = utf8.UTFMax
    28  	_ = (*regexp.Regexp)(nil)
    29  	_ = (*strings.Reader)(nil)
    30  	_ = net.IPv4len
    31  	_ = time.Duration(0)
    32  	_ = (*url.URL)(nil)
    33  	_ = (*mail.Address)(nil)
    34  	_ = anypb.Any{}
    35  	_ = sort.Sort
    36  )
    37  
    38  // Validate checks the field values on RBAC with the rules defined in the proto
    39  // definition for this message. If any rules are violated, the first error
    40  // encountered is returned, or nil if there are no violations.
    41  func (m *RBAC) Validate() error {
    42  	return m.validate(false)
    43  }
    44  
    45  // ValidateAll checks the field values on RBAC with the rules defined in the
    46  // proto definition for this message. If any rules are violated, the result is
    47  // a list of violation errors wrapped in RBACMultiError, or nil if none found.
    48  func (m *RBAC) ValidateAll() error {
    49  	return m.validate(true)
    50  }
    51  
    52  func (m *RBAC) validate(all bool) error {
    53  	if m == nil {
    54  		return nil
    55  	}
    56  
    57  	var errors []error
    58  
    59  	// no validation rules for Action
    60  
    61  	{
    62  		sorted_keys := make([]string, len(m.GetPolicies()))
    63  		i := 0
    64  		for key := range m.GetPolicies() {
    65  			sorted_keys[i] = key
    66  			i++
    67  		}
    68  		sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] })
    69  		for _, key := range sorted_keys {
    70  			val := m.GetPolicies()[key]
    71  			_ = val
    72  
    73  			// no validation rules for Policies[key]
    74  
    75  			if all {
    76  				switch v := interface{}(val).(type) {
    77  				case interface{ ValidateAll() error }:
    78  					if err := v.ValidateAll(); err != nil {
    79  						errors = append(errors, RBACValidationError{
    80  							field:  fmt.Sprintf("Policies[%v]", key),
    81  							reason: "embedded message failed validation",
    82  							cause:  err,
    83  						})
    84  					}
    85  				case interface{ Validate() error }:
    86  					if err := v.Validate(); err != nil {
    87  						errors = append(errors, RBACValidationError{
    88  							field:  fmt.Sprintf("Policies[%v]", key),
    89  							reason: "embedded message failed validation",
    90  							cause:  err,
    91  						})
    92  					}
    93  				}
    94  			} else if v, ok := interface{}(val).(interface{ Validate() error }); ok {
    95  				if err := v.Validate(); err != nil {
    96  					return RBACValidationError{
    97  						field:  fmt.Sprintf("Policies[%v]", key),
    98  						reason: "embedded message failed validation",
    99  						cause:  err,
   100  					}
   101  				}
   102  			}
   103  
   104  		}
   105  	}
   106  
   107  	if len(errors) > 0 {
   108  		return RBACMultiError(errors)
   109  	}
   110  
   111  	return nil
   112  }
   113  
   114  // RBACMultiError is an error wrapping multiple validation errors returned by
   115  // RBAC.ValidateAll() if the designated constraints aren't met.
   116  type RBACMultiError []error
   117  
   118  // Error returns a concatenation of all the error messages it wraps.
   119  func (m RBACMultiError) Error() string {
   120  	var msgs []string
   121  	for _, err := range m {
   122  		msgs = append(msgs, err.Error())
   123  	}
   124  	return strings.Join(msgs, "; ")
   125  }
   126  
   127  // AllErrors returns a list of validation violation errors.
   128  func (m RBACMultiError) AllErrors() []error { return m }
   129  
   130  // RBACValidationError is the validation error returned by RBAC.Validate if the
   131  // designated constraints aren't met.
   132  type RBACValidationError struct {
   133  	field  string
   134  	reason string
   135  	cause  error
   136  	key    bool
   137  }
   138  
   139  // Field function returns field value.
   140  func (e RBACValidationError) Field() string { return e.field }
   141  
   142  // Reason function returns reason value.
   143  func (e RBACValidationError) Reason() string { return e.reason }
   144  
   145  // Cause function returns cause value.
   146  func (e RBACValidationError) Cause() error { return e.cause }
   147  
   148  // Key function returns key value.
   149  func (e RBACValidationError) Key() bool { return e.key }
   150  
   151  // ErrorName returns error name.
   152  func (e RBACValidationError) ErrorName() string { return "RBACValidationError" }
   153  
   154  // Error satisfies the builtin error interface
   155  func (e RBACValidationError) Error() string {
   156  	cause := ""
   157  	if e.cause != nil {
   158  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   159  	}
   160  
   161  	key := ""
   162  	if e.key {
   163  		key = "key for "
   164  	}
   165  
   166  	return fmt.Sprintf(
   167  		"invalid %sRBAC.%s: %s%s",
   168  		key,
   169  		e.field,
   170  		e.reason,
   171  		cause)
   172  }
   173  
   174  var _ error = RBACValidationError{}
   175  
   176  var _ interface {
   177  	Field() string
   178  	Reason() string
   179  	Key() bool
   180  	Cause() error
   181  	ErrorName() string
   182  } = RBACValidationError{}
   183  
   184  // Validate checks the field values on Policy with the rules defined in the
   185  // proto definition for this message. If any rules are violated, the first
   186  // error encountered is returned, or nil if there are no violations.
   187  func (m *Policy) Validate() error {
   188  	return m.validate(false)
   189  }
   190  
   191  // ValidateAll checks the field values on Policy with the rules defined in the
   192  // proto definition for this message. If any rules are violated, the result is
   193  // a list of violation errors wrapped in PolicyMultiError, or nil if none found.
   194  func (m *Policy) ValidateAll() error {
   195  	return m.validate(true)
   196  }
   197  
   198  func (m *Policy) validate(all bool) error {
   199  	if m == nil {
   200  		return nil
   201  	}
   202  
   203  	var errors []error
   204  
   205  	if len(m.GetPermissions()) < 1 {
   206  		err := PolicyValidationError{
   207  			field:  "Permissions",
   208  			reason: "value must contain at least 1 item(s)",
   209  		}
   210  		if !all {
   211  			return err
   212  		}
   213  		errors = append(errors, err)
   214  	}
   215  
   216  	for idx, item := range m.GetPermissions() {
   217  		_, _ = idx, item
   218  
   219  		if all {
   220  			switch v := interface{}(item).(type) {
   221  			case interface{ ValidateAll() error }:
   222  				if err := v.ValidateAll(); err != nil {
   223  					errors = append(errors, PolicyValidationError{
   224  						field:  fmt.Sprintf("Permissions[%v]", idx),
   225  						reason: "embedded message failed validation",
   226  						cause:  err,
   227  					})
   228  				}
   229  			case interface{ Validate() error }:
   230  				if err := v.Validate(); err != nil {
   231  					errors = append(errors, PolicyValidationError{
   232  						field:  fmt.Sprintf("Permissions[%v]", idx),
   233  						reason: "embedded message failed validation",
   234  						cause:  err,
   235  					})
   236  				}
   237  			}
   238  		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   239  			if err := v.Validate(); err != nil {
   240  				return PolicyValidationError{
   241  					field:  fmt.Sprintf("Permissions[%v]", idx),
   242  					reason: "embedded message failed validation",
   243  					cause:  err,
   244  				}
   245  			}
   246  		}
   247  
   248  	}
   249  
   250  	if len(m.GetPrincipals()) < 1 {
   251  		err := PolicyValidationError{
   252  			field:  "Principals",
   253  			reason: "value must contain at least 1 item(s)",
   254  		}
   255  		if !all {
   256  			return err
   257  		}
   258  		errors = append(errors, err)
   259  	}
   260  
   261  	for idx, item := range m.GetPrincipals() {
   262  		_, _ = idx, item
   263  
   264  		if all {
   265  			switch v := interface{}(item).(type) {
   266  			case interface{ ValidateAll() error }:
   267  				if err := v.ValidateAll(); err != nil {
   268  					errors = append(errors, PolicyValidationError{
   269  						field:  fmt.Sprintf("Principals[%v]", idx),
   270  						reason: "embedded message failed validation",
   271  						cause:  err,
   272  					})
   273  				}
   274  			case interface{ Validate() error }:
   275  				if err := v.Validate(); err != nil {
   276  					errors = append(errors, PolicyValidationError{
   277  						field:  fmt.Sprintf("Principals[%v]", idx),
   278  						reason: "embedded message failed validation",
   279  						cause:  err,
   280  					})
   281  				}
   282  			}
   283  		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   284  			if err := v.Validate(); err != nil {
   285  				return PolicyValidationError{
   286  					field:  fmt.Sprintf("Principals[%v]", idx),
   287  					reason: "embedded message failed validation",
   288  					cause:  err,
   289  				}
   290  			}
   291  		}
   292  
   293  	}
   294  
   295  	if all {
   296  		switch v := interface{}(m.GetCondition()).(type) {
   297  		case interface{ ValidateAll() error }:
   298  			if err := v.ValidateAll(); err != nil {
   299  				errors = append(errors, PolicyValidationError{
   300  					field:  "Condition",
   301  					reason: "embedded message failed validation",
   302  					cause:  err,
   303  				})
   304  			}
   305  		case interface{ Validate() error }:
   306  			if err := v.Validate(); err != nil {
   307  				errors = append(errors, PolicyValidationError{
   308  					field:  "Condition",
   309  					reason: "embedded message failed validation",
   310  					cause:  err,
   311  				})
   312  			}
   313  		}
   314  	} else if v, ok := interface{}(m.GetCondition()).(interface{ Validate() error }); ok {
   315  		if err := v.Validate(); err != nil {
   316  			return PolicyValidationError{
   317  				field:  "Condition",
   318  				reason: "embedded message failed validation",
   319  				cause:  err,
   320  			}
   321  		}
   322  	}
   323  
   324  	if len(errors) > 0 {
   325  		return PolicyMultiError(errors)
   326  	}
   327  
   328  	return nil
   329  }
   330  
   331  // PolicyMultiError is an error wrapping multiple validation errors returned by
   332  // Policy.ValidateAll() if the designated constraints aren't met.
   333  type PolicyMultiError []error
   334  
   335  // Error returns a concatenation of all the error messages it wraps.
   336  func (m PolicyMultiError) Error() string {
   337  	var msgs []string
   338  	for _, err := range m {
   339  		msgs = append(msgs, err.Error())
   340  	}
   341  	return strings.Join(msgs, "; ")
   342  }
   343  
   344  // AllErrors returns a list of validation violation errors.
   345  func (m PolicyMultiError) AllErrors() []error { return m }
   346  
   347  // PolicyValidationError is the validation error returned by Policy.Validate if
   348  // the designated constraints aren't met.
   349  type PolicyValidationError struct {
   350  	field  string
   351  	reason string
   352  	cause  error
   353  	key    bool
   354  }
   355  
   356  // Field function returns field value.
   357  func (e PolicyValidationError) Field() string { return e.field }
   358  
   359  // Reason function returns reason value.
   360  func (e PolicyValidationError) Reason() string { return e.reason }
   361  
   362  // Cause function returns cause value.
   363  func (e PolicyValidationError) Cause() error { return e.cause }
   364  
   365  // Key function returns key value.
   366  func (e PolicyValidationError) Key() bool { return e.key }
   367  
   368  // ErrorName returns error name.
   369  func (e PolicyValidationError) ErrorName() string { return "PolicyValidationError" }
   370  
   371  // Error satisfies the builtin error interface
   372  func (e PolicyValidationError) Error() string {
   373  	cause := ""
   374  	if e.cause != nil {
   375  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   376  	}
   377  
   378  	key := ""
   379  	if e.key {
   380  		key = "key for "
   381  	}
   382  
   383  	return fmt.Sprintf(
   384  		"invalid %sPolicy.%s: %s%s",
   385  		key,
   386  		e.field,
   387  		e.reason,
   388  		cause)
   389  }
   390  
   391  var _ error = PolicyValidationError{}
   392  
   393  var _ interface {
   394  	Field() string
   395  	Reason() string
   396  	Key() bool
   397  	Cause() error
   398  	ErrorName() string
   399  } = PolicyValidationError{}
   400  
   401  // Validate checks the field values on Permission with the rules defined in the
   402  // proto definition for this message. If any rules are violated, the first
   403  // error encountered is returned, or nil if there are no violations.
   404  func (m *Permission) Validate() error {
   405  	return m.validate(false)
   406  }
   407  
   408  // ValidateAll checks the field values on Permission with the rules defined in
   409  // the proto definition for this message. If any rules are violated, the
   410  // result is a list of violation errors wrapped in PermissionMultiError, or
   411  // nil if none found.
   412  func (m *Permission) ValidateAll() error {
   413  	return m.validate(true)
   414  }
   415  
   416  func (m *Permission) validate(all bool) error {
   417  	if m == nil {
   418  		return nil
   419  	}
   420  
   421  	var errors []error
   422  
   423  	oneofRulePresent := false
   424  	switch v := m.Rule.(type) {
   425  	case *Permission_AndRules:
   426  		if v == nil {
   427  			err := PermissionValidationError{
   428  				field:  "Rule",
   429  				reason: "oneof value cannot be a typed-nil",
   430  			}
   431  			if !all {
   432  				return err
   433  			}
   434  			errors = append(errors, err)
   435  		}
   436  		oneofRulePresent = true
   437  
   438  		if all {
   439  			switch v := interface{}(m.GetAndRules()).(type) {
   440  			case interface{ ValidateAll() error }:
   441  				if err := v.ValidateAll(); err != nil {
   442  					errors = append(errors, PermissionValidationError{
   443  						field:  "AndRules",
   444  						reason: "embedded message failed validation",
   445  						cause:  err,
   446  					})
   447  				}
   448  			case interface{ Validate() error }:
   449  				if err := v.Validate(); err != nil {
   450  					errors = append(errors, PermissionValidationError{
   451  						field:  "AndRules",
   452  						reason: "embedded message failed validation",
   453  						cause:  err,
   454  					})
   455  				}
   456  			}
   457  		} else if v, ok := interface{}(m.GetAndRules()).(interface{ Validate() error }); ok {
   458  			if err := v.Validate(); err != nil {
   459  				return PermissionValidationError{
   460  					field:  "AndRules",
   461  					reason: "embedded message failed validation",
   462  					cause:  err,
   463  				}
   464  			}
   465  		}
   466  
   467  	case *Permission_OrRules:
   468  		if v == nil {
   469  			err := PermissionValidationError{
   470  				field:  "Rule",
   471  				reason: "oneof value cannot be a typed-nil",
   472  			}
   473  			if !all {
   474  				return err
   475  			}
   476  			errors = append(errors, err)
   477  		}
   478  		oneofRulePresent = true
   479  
   480  		if all {
   481  			switch v := interface{}(m.GetOrRules()).(type) {
   482  			case interface{ ValidateAll() error }:
   483  				if err := v.ValidateAll(); err != nil {
   484  					errors = append(errors, PermissionValidationError{
   485  						field:  "OrRules",
   486  						reason: "embedded message failed validation",
   487  						cause:  err,
   488  					})
   489  				}
   490  			case interface{ Validate() error }:
   491  				if err := v.Validate(); err != nil {
   492  					errors = append(errors, PermissionValidationError{
   493  						field:  "OrRules",
   494  						reason: "embedded message failed validation",
   495  						cause:  err,
   496  					})
   497  				}
   498  			}
   499  		} else if v, ok := interface{}(m.GetOrRules()).(interface{ Validate() error }); ok {
   500  			if err := v.Validate(); err != nil {
   501  				return PermissionValidationError{
   502  					field:  "OrRules",
   503  					reason: "embedded message failed validation",
   504  					cause:  err,
   505  				}
   506  			}
   507  		}
   508  
   509  	case *Permission_Any:
   510  		if v == nil {
   511  			err := PermissionValidationError{
   512  				field:  "Rule",
   513  				reason: "oneof value cannot be a typed-nil",
   514  			}
   515  			if !all {
   516  				return err
   517  			}
   518  			errors = append(errors, err)
   519  		}
   520  		oneofRulePresent = true
   521  
   522  		if m.GetAny() != true {
   523  			err := PermissionValidationError{
   524  				field:  "Any",
   525  				reason: "value must equal true",
   526  			}
   527  			if !all {
   528  				return err
   529  			}
   530  			errors = append(errors, err)
   531  		}
   532  
   533  	case *Permission_Header:
   534  		if v == nil {
   535  			err := PermissionValidationError{
   536  				field:  "Rule",
   537  				reason: "oneof value cannot be a typed-nil",
   538  			}
   539  			if !all {
   540  				return err
   541  			}
   542  			errors = append(errors, err)
   543  		}
   544  		oneofRulePresent = true
   545  
   546  		if all {
   547  			switch v := interface{}(m.GetHeader()).(type) {
   548  			case interface{ ValidateAll() error }:
   549  				if err := v.ValidateAll(); err != nil {
   550  					errors = append(errors, PermissionValidationError{
   551  						field:  "Header",
   552  						reason: "embedded message failed validation",
   553  						cause:  err,
   554  					})
   555  				}
   556  			case interface{ Validate() error }:
   557  				if err := v.Validate(); err != nil {
   558  					errors = append(errors, PermissionValidationError{
   559  						field:  "Header",
   560  						reason: "embedded message failed validation",
   561  						cause:  err,
   562  					})
   563  				}
   564  			}
   565  		} else if v, ok := interface{}(m.GetHeader()).(interface{ Validate() error }); ok {
   566  			if err := v.Validate(); err != nil {
   567  				return PermissionValidationError{
   568  					field:  "Header",
   569  					reason: "embedded message failed validation",
   570  					cause:  err,
   571  				}
   572  			}
   573  		}
   574  
   575  	case *Permission_UrlPath:
   576  		if v == nil {
   577  			err := PermissionValidationError{
   578  				field:  "Rule",
   579  				reason: "oneof value cannot be a typed-nil",
   580  			}
   581  			if !all {
   582  				return err
   583  			}
   584  			errors = append(errors, err)
   585  		}
   586  		oneofRulePresent = true
   587  
   588  		if all {
   589  			switch v := interface{}(m.GetUrlPath()).(type) {
   590  			case interface{ ValidateAll() error }:
   591  				if err := v.ValidateAll(); err != nil {
   592  					errors = append(errors, PermissionValidationError{
   593  						field:  "UrlPath",
   594  						reason: "embedded message failed validation",
   595  						cause:  err,
   596  					})
   597  				}
   598  			case interface{ Validate() error }:
   599  				if err := v.Validate(); err != nil {
   600  					errors = append(errors, PermissionValidationError{
   601  						field:  "UrlPath",
   602  						reason: "embedded message failed validation",
   603  						cause:  err,
   604  					})
   605  				}
   606  			}
   607  		} else if v, ok := interface{}(m.GetUrlPath()).(interface{ Validate() error }); ok {
   608  			if err := v.Validate(); err != nil {
   609  				return PermissionValidationError{
   610  					field:  "UrlPath",
   611  					reason: "embedded message failed validation",
   612  					cause:  err,
   613  				}
   614  			}
   615  		}
   616  
   617  	case *Permission_DestinationIp:
   618  		if v == nil {
   619  			err := PermissionValidationError{
   620  				field:  "Rule",
   621  				reason: "oneof value cannot be a typed-nil",
   622  			}
   623  			if !all {
   624  				return err
   625  			}
   626  			errors = append(errors, err)
   627  		}
   628  		oneofRulePresent = true
   629  
   630  		if all {
   631  			switch v := interface{}(m.GetDestinationIp()).(type) {
   632  			case interface{ ValidateAll() error }:
   633  				if err := v.ValidateAll(); err != nil {
   634  					errors = append(errors, PermissionValidationError{
   635  						field:  "DestinationIp",
   636  						reason: "embedded message failed validation",
   637  						cause:  err,
   638  					})
   639  				}
   640  			case interface{ Validate() error }:
   641  				if err := v.Validate(); err != nil {
   642  					errors = append(errors, PermissionValidationError{
   643  						field:  "DestinationIp",
   644  						reason: "embedded message failed validation",
   645  						cause:  err,
   646  					})
   647  				}
   648  			}
   649  		} else if v, ok := interface{}(m.GetDestinationIp()).(interface{ Validate() error }); ok {
   650  			if err := v.Validate(); err != nil {
   651  				return PermissionValidationError{
   652  					field:  "DestinationIp",
   653  					reason: "embedded message failed validation",
   654  					cause:  err,
   655  				}
   656  			}
   657  		}
   658  
   659  	case *Permission_DestinationPort:
   660  		if v == nil {
   661  			err := PermissionValidationError{
   662  				field:  "Rule",
   663  				reason: "oneof value cannot be a typed-nil",
   664  			}
   665  			if !all {
   666  				return err
   667  			}
   668  			errors = append(errors, err)
   669  		}
   670  		oneofRulePresent = true
   671  
   672  		if m.GetDestinationPort() > 65535 {
   673  			err := PermissionValidationError{
   674  				field:  "DestinationPort",
   675  				reason: "value must be less than or equal to 65535",
   676  			}
   677  			if !all {
   678  				return err
   679  			}
   680  			errors = append(errors, err)
   681  		}
   682  
   683  	case *Permission_Metadata:
   684  		if v == nil {
   685  			err := PermissionValidationError{
   686  				field:  "Rule",
   687  				reason: "oneof value cannot be a typed-nil",
   688  			}
   689  			if !all {
   690  				return err
   691  			}
   692  			errors = append(errors, err)
   693  		}
   694  		oneofRulePresent = true
   695  
   696  		if all {
   697  			switch v := interface{}(m.GetMetadata()).(type) {
   698  			case interface{ ValidateAll() error }:
   699  				if err := v.ValidateAll(); err != nil {
   700  					errors = append(errors, PermissionValidationError{
   701  						field:  "Metadata",
   702  						reason: "embedded message failed validation",
   703  						cause:  err,
   704  					})
   705  				}
   706  			case interface{ Validate() error }:
   707  				if err := v.Validate(); err != nil {
   708  					errors = append(errors, PermissionValidationError{
   709  						field:  "Metadata",
   710  						reason: "embedded message failed validation",
   711  						cause:  err,
   712  					})
   713  				}
   714  			}
   715  		} else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok {
   716  			if err := v.Validate(); err != nil {
   717  				return PermissionValidationError{
   718  					field:  "Metadata",
   719  					reason: "embedded message failed validation",
   720  					cause:  err,
   721  				}
   722  			}
   723  		}
   724  
   725  	case *Permission_NotRule:
   726  		if v == nil {
   727  			err := PermissionValidationError{
   728  				field:  "Rule",
   729  				reason: "oneof value cannot be a typed-nil",
   730  			}
   731  			if !all {
   732  				return err
   733  			}
   734  			errors = append(errors, err)
   735  		}
   736  		oneofRulePresent = true
   737  
   738  		if all {
   739  			switch v := interface{}(m.GetNotRule()).(type) {
   740  			case interface{ ValidateAll() error }:
   741  				if err := v.ValidateAll(); err != nil {
   742  					errors = append(errors, PermissionValidationError{
   743  						field:  "NotRule",
   744  						reason: "embedded message failed validation",
   745  						cause:  err,
   746  					})
   747  				}
   748  			case interface{ Validate() error }:
   749  				if err := v.Validate(); err != nil {
   750  					errors = append(errors, PermissionValidationError{
   751  						field:  "NotRule",
   752  						reason: "embedded message failed validation",
   753  						cause:  err,
   754  					})
   755  				}
   756  			}
   757  		} else if v, ok := interface{}(m.GetNotRule()).(interface{ Validate() error }); ok {
   758  			if err := v.Validate(); err != nil {
   759  				return PermissionValidationError{
   760  					field:  "NotRule",
   761  					reason: "embedded message failed validation",
   762  					cause:  err,
   763  				}
   764  			}
   765  		}
   766  
   767  	case *Permission_RequestedServerName:
   768  		if v == nil {
   769  			err := PermissionValidationError{
   770  				field:  "Rule",
   771  				reason: "oneof value cannot be a typed-nil",
   772  			}
   773  			if !all {
   774  				return err
   775  			}
   776  			errors = append(errors, err)
   777  		}
   778  		oneofRulePresent = true
   779  
   780  		if all {
   781  			switch v := interface{}(m.GetRequestedServerName()).(type) {
   782  			case interface{ ValidateAll() error }:
   783  				if err := v.ValidateAll(); err != nil {
   784  					errors = append(errors, PermissionValidationError{
   785  						field:  "RequestedServerName",
   786  						reason: "embedded message failed validation",
   787  						cause:  err,
   788  					})
   789  				}
   790  			case interface{ Validate() error }:
   791  				if err := v.Validate(); err != nil {
   792  					errors = append(errors, PermissionValidationError{
   793  						field:  "RequestedServerName",
   794  						reason: "embedded message failed validation",
   795  						cause:  err,
   796  					})
   797  				}
   798  			}
   799  		} else if v, ok := interface{}(m.GetRequestedServerName()).(interface{ Validate() error }); ok {
   800  			if err := v.Validate(); err != nil {
   801  				return PermissionValidationError{
   802  					field:  "RequestedServerName",
   803  					reason: "embedded message failed validation",
   804  					cause:  err,
   805  				}
   806  			}
   807  		}
   808  
   809  	default:
   810  		_ = v // ensures v is used
   811  	}
   812  	if !oneofRulePresent {
   813  		err := PermissionValidationError{
   814  			field:  "Rule",
   815  			reason: "value is required",
   816  		}
   817  		if !all {
   818  			return err
   819  		}
   820  		errors = append(errors, err)
   821  	}
   822  
   823  	if len(errors) > 0 {
   824  		return PermissionMultiError(errors)
   825  	}
   826  
   827  	return nil
   828  }
   829  
   830  // PermissionMultiError is an error wrapping multiple validation errors
   831  // returned by Permission.ValidateAll() if the designated constraints aren't met.
   832  type PermissionMultiError []error
   833  
   834  // Error returns a concatenation of all the error messages it wraps.
   835  func (m PermissionMultiError) Error() string {
   836  	var msgs []string
   837  	for _, err := range m {
   838  		msgs = append(msgs, err.Error())
   839  	}
   840  	return strings.Join(msgs, "; ")
   841  }
   842  
   843  // AllErrors returns a list of validation violation errors.
   844  func (m PermissionMultiError) AllErrors() []error { return m }
   845  
   846  // PermissionValidationError is the validation error returned by
   847  // Permission.Validate if the designated constraints aren't met.
   848  type PermissionValidationError struct {
   849  	field  string
   850  	reason string
   851  	cause  error
   852  	key    bool
   853  }
   854  
   855  // Field function returns field value.
   856  func (e PermissionValidationError) Field() string { return e.field }
   857  
   858  // Reason function returns reason value.
   859  func (e PermissionValidationError) Reason() string { return e.reason }
   860  
   861  // Cause function returns cause value.
   862  func (e PermissionValidationError) Cause() error { return e.cause }
   863  
   864  // Key function returns key value.
   865  func (e PermissionValidationError) Key() bool { return e.key }
   866  
   867  // ErrorName returns error name.
   868  func (e PermissionValidationError) ErrorName() string { return "PermissionValidationError" }
   869  
   870  // Error satisfies the builtin error interface
   871  func (e PermissionValidationError) Error() string {
   872  	cause := ""
   873  	if e.cause != nil {
   874  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   875  	}
   876  
   877  	key := ""
   878  	if e.key {
   879  		key = "key for "
   880  	}
   881  
   882  	return fmt.Sprintf(
   883  		"invalid %sPermission.%s: %s%s",
   884  		key,
   885  		e.field,
   886  		e.reason,
   887  		cause)
   888  }
   889  
   890  var _ error = PermissionValidationError{}
   891  
   892  var _ interface {
   893  	Field() string
   894  	Reason() string
   895  	Key() bool
   896  	Cause() error
   897  	ErrorName() string
   898  } = PermissionValidationError{}
   899  
   900  // Validate checks the field values on Principal with the rules defined in the
   901  // proto definition for this message. If any rules are violated, the first
   902  // error encountered is returned, or nil if there are no violations.
   903  func (m *Principal) Validate() error {
   904  	return m.validate(false)
   905  }
   906  
   907  // ValidateAll checks the field values on Principal with the rules defined in
   908  // the proto definition for this message. If any rules are violated, the
   909  // result is a list of violation errors wrapped in PrincipalMultiError, or nil
   910  // if none found.
   911  func (m *Principal) ValidateAll() error {
   912  	return m.validate(true)
   913  }
   914  
   915  func (m *Principal) validate(all bool) error {
   916  	if m == nil {
   917  		return nil
   918  	}
   919  
   920  	var errors []error
   921  
   922  	oneofIdentifierPresent := false
   923  	switch v := m.Identifier.(type) {
   924  	case *Principal_AndIds:
   925  		if v == nil {
   926  			err := PrincipalValidationError{
   927  				field:  "Identifier",
   928  				reason: "oneof value cannot be a typed-nil",
   929  			}
   930  			if !all {
   931  				return err
   932  			}
   933  			errors = append(errors, err)
   934  		}
   935  		oneofIdentifierPresent = true
   936  
   937  		if all {
   938  			switch v := interface{}(m.GetAndIds()).(type) {
   939  			case interface{ ValidateAll() error }:
   940  				if err := v.ValidateAll(); err != nil {
   941  					errors = append(errors, PrincipalValidationError{
   942  						field:  "AndIds",
   943  						reason: "embedded message failed validation",
   944  						cause:  err,
   945  					})
   946  				}
   947  			case interface{ Validate() error }:
   948  				if err := v.Validate(); err != nil {
   949  					errors = append(errors, PrincipalValidationError{
   950  						field:  "AndIds",
   951  						reason: "embedded message failed validation",
   952  						cause:  err,
   953  					})
   954  				}
   955  			}
   956  		} else if v, ok := interface{}(m.GetAndIds()).(interface{ Validate() error }); ok {
   957  			if err := v.Validate(); err != nil {
   958  				return PrincipalValidationError{
   959  					field:  "AndIds",
   960  					reason: "embedded message failed validation",
   961  					cause:  err,
   962  				}
   963  			}
   964  		}
   965  
   966  	case *Principal_OrIds:
   967  		if v == nil {
   968  			err := PrincipalValidationError{
   969  				field:  "Identifier",
   970  				reason: "oneof value cannot be a typed-nil",
   971  			}
   972  			if !all {
   973  				return err
   974  			}
   975  			errors = append(errors, err)
   976  		}
   977  		oneofIdentifierPresent = true
   978  
   979  		if all {
   980  			switch v := interface{}(m.GetOrIds()).(type) {
   981  			case interface{ ValidateAll() error }:
   982  				if err := v.ValidateAll(); err != nil {
   983  					errors = append(errors, PrincipalValidationError{
   984  						field:  "OrIds",
   985  						reason: "embedded message failed validation",
   986  						cause:  err,
   987  					})
   988  				}
   989  			case interface{ Validate() error }:
   990  				if err := v.Validate(); err != nil {
   991  					errors = append(errors, PrincipalValidationError{
   992  						field:  "OrIds",
   993  						reason: "embedded message failed validation",
   994  						cause:  err,
   995  					})
   996  				}
   997  			}
   998  		} else if v, ok := interface{}(m.GetOrIds()).(interface{ Validate() error }); ok {
   999  			if err := v.Validate(); err != nil {
  1000  				return PrincipalValidationError{
  1001  					field:  "OrIds",
  1002  					reason: "embedded message failed validation",
  1003  					cause:  err,
  1004  				}
  1005  			}
  1006  		}
  1007  
  1008  	case *Principal_Any:
  1009  		if v == nil {
  1010  			err := PrincipalValidationError{
  1011  				field:  "Identifier",
  1012  				reason: "oneof value cannot be a typed-nil",
  1013  			}
  1014  			if !all {
  1015  				return err
  1016  			}
  1017  			errors = append(errors, err)
  1018  		}
  1019  		oneofIdentifierPresent = true
  1020  
  1021  		if m.GetAny() != true {
  1022  			err := PrincipalValidationError{
  1023  				field:  "Any",
  1024  				reason: "value must equal true",
  1025  			}
  1026  			if !all {
  1027  				return err
  1028  			}
  1029  			errors = append(errors, err)
  1030  		}
  1031  
  1032  	case *Principal_Authenticated_:
  1033  		if v == nil {
  1034  			err := PrincipalValidationError{
  1035  				field:  "Identifier",
  1036  				reason: "oneof value cannot be a typed-nil",
  1037  			}
  1038  			if !all {
  1039  				return err
  1040  			}
  1041  			errors = append(errors, err)
  1042  		}
  1043  		oneofIdentifierPresent = true
  1044  
  1045  		if all {
  1046  			switch v := interface{}(m.GetAuthenticated()).(type) {
  1047  			case interface{ ValidateAll() error }:
  1048  				if err := v.ValidateAll(); err != nil {
  1049  					errors = append(errors, PrincipalValidationError{
  1050  						field:  "Authenticated",
  1051  						reason: "embedded message failed validation",
  1052  						cause:  err,
  1053  					})
  1054  				}
  1055  			case interface{ Validate() error }:
  1056  				if err := v.Validate(); err != nil {
  1057  					errors = append(errors, PrincipalValidationError{
  1058  						field:  "Authenticated",
  1059  						reason: "embedded message failed validation",
  1060  						cause:  err,
  1061  					})
  1062  				}
  1063  			}
  1064  		} else if v, ok := interface{}(m.GetAuthenticated()).(interface{ Validate() error }); ok {
  1065  			if err := v.Validate(); err != nil {
  1066  				return PrincipalValidationError{
  1067  					field:  "Authenticated",
  1068  					reason: "embedded message failed validation",
  1069  					cause:  err,
  1070  				}
  1071  			}
  1072  		}
  1073  
  1074  	case *Principal_SourceIp:
  1075  		if v == nil {
  1076  			err := PrincipalValidationError{
  1077  				field:  "Identifier",
  1078  				reason: "oneof value cannot be a typed-nil",
  1079  			}
  1080  			if !all {
  1081  				return err
  1082  			}
  1083  			errors = append(errors, err)
  1084  		}
  1085  		oneofIdentifierPresent = true
  1086  
  1087  		if all {
  1088  			switch v := interface{}(m.GetSourceIp()).(type) {
  1089  			case interface{ ValidateAll() error }:
  1090  				if err := v.ValidateAll(); err != nil {
  1091  					errors = append(errors, PrincipalValidationError{
  1092  						field:  "SourceIp",
  1093  						reason: "embedded message failed validation",
  1094  						cause:  err,
  1095  					})
  1096  				}
  1097  			case interface{ Validate() error }:
  1098  				if err := v.Validate(); err != nil {
  1099  					errors = append(errors, PrincipalValidationError{
  1100  						field:  "SourceIp",
  1101  						reason: "embedded message failed validation",
  1102  						cause:  err,
  1103  					})
  1104  				}
  1105  			}
  1106  		} else if v, ok := interface{}(m.GetSourceIp()).(interface{ Validate() error }); ok {
  1107  			if err := v.Validate(); err != nil {
  1108  				return PrincipalValidationError{
  1109  					field:  "SourceIp",
  1110  					reason: "embedded message failed validation",
  1111  					cause:  err,
  1112  				}
  1113  			}
  1114  		}
  1115  
  1116  	case *Principal_DirectRemoteIp:
  1117  		if v == nil {
  1118  			err := PrincipalValidationError{
  1119  				field:  "Identifier",
  1120  				reason: "oneof value cannot be a typed-nil",
  1121  			}
  1122  			if !all {
  1123  				return err
  1124  			}
  1125  			errors = append(errors, err)
  1126  		}
  1127  		oneofIdentifierPresent = true
  1128  
  1129  		if all {
  1130  			switch v := interface{}(m.GetDirectRemoteIp()).(type) {
  1131  			case interface{ ValidateAll() error }:
  1132  				if err := v.ValidateAll(); err != nil {
  1133  					errors = append(errors, PrincipalValidationError{
  1134  						field:  "DirectRemoteIp",
  1135  						reason: "embedded message failed validation",
  1136  						cause:  err,
  1137  					})
  1138  				}
  1139  			case interface{ Validate() error }:
  1140  				if err := v.Validate(); err != nil {
  1141  					errors = append(errors, PrincipalValidationError{
  1142  						field:  "DirectRemoteIp",
  1143  						reason: "embedded message failed validation",
  1144  						cause:  err,
  1145  					})
  1146  				}
  1147  			}
  1148  		} else if v, ok := interface{}(m.GetDirectRemoteIp()).(interface{ Validate() error }); ok {
  1149  			if err := v.Validate(); err != nil {
  1150  				return PrincipalValidationError{
  1151  					field:  "DirectRemoteIp",
  1152  					reason: "embedded message failed validation",
  1153  					cause:  err,
  1154  				}
  1155  			}
  1156  		}
  1157  
  1158  	case *Principal_RemoteIp:
  1159  		if v == nil {
  1160  			err := PrincipalValidationError{
  1161  				field:  "Identifier",
  1162  				reason: "oneof value cannot be a typed-nil",
  1163  			}
  1164  			if !all {
  1165  				return err
  1166  			}
  1167  			errors = append(errors, err)
  1168  		}
  1169  		oneofIdentifierPresent = true
  1170  
  1171  		if all {
  1172  			switch v := interface{}(m.GetRemoteIp()).(type) {
  1173  			case interface{ ValidateAll() error }:
  1174  				if err := v.ValidateAll(); err != nil {
  1175  					errors = append(errors, PrincipalValidationError{
  1176  						field:  "RemoteIp",
  1177  						reason: "embedded message failed validation",
  1178  						cause:  err,
  1179  					})
  1180  				}
  1181  			case interface{ Validate() error }:
  1182  				if err := v.Validate(); err != nil {
  1183  					errors = append(errors, PrincipalValidationError{
  1184  						field:  "RemoteIp",
  1185  						reason: "embedded message failed validation",
  1186  						cause:  err,
  1187  					})
  1188  				}
  1189  			}
  1190  		} else if v, ok := interface{}(m.GetRemoteIp()).(interface{ Validate() error }); ok {
  1191  			if err := v.Validate(); err != nil {
  1192  				return PrincipalValidationError{
  1193  					field:  "RemoteIp",
  1194  					reason: "embedded message failed validation",
  1195  					cause:  err,
  1196  				}
  1197  			}
  1198  		}
  1199  
  1200  	case *Principal_Header:
  1201  		if v == nil {
  1202  			err := PrincipalValidationError{
  1203  				field:  "Identifier",
  1204  				reason: "oneof value cannot be a typed-nil",
  1205  			}
  1206  			if !all {
  1207  				return err
  1208  			}
  1209  			errors = append(errors, err)
  1210  		}
  1211  		oneofIdentifierPresent = true
  1212  
  1213  		if all {
  1214  			switch v := interface{}(m.GetHeader()).(type) {
  1215  			case interface{ ValidateAll() error }:
  1216  				if err := v.ValidateAll(); err != nil {
  1217  					errors = append(errors, PrincipalValidationError{
  1218  						field:  "Header",
  1219  						reason: "embedded message failed validation",
  1220  						cause:  err,
  1221  					})
  1222  				}
  1223  			case interface{ Validate() error }:
  1224  				if err := v.Validate(); err != nil {
  1225  					errors = append(errors, PrincipalValidationError{
  1226  						field:  "Header",
  1227  						reason: "embedded message failed validation",
  1228  						cause:  err,
  1229  					})
  1230  				}
  1231  			}
  1232  		} else if v, ok := interface{}(m.GetHeader()).(interface{ Validate() error }); ok {
  1233  			if err := v.Validate(); err != nil {
  1234  				return PrincipalValidationError{
  1235  					field:  "Header",
  1236  					reason: "embedded message failed validation",
  1237  					cause:  err,
  1238  				}
  1239  			}
  1240  		}
  1241  
  1242  	case *Principal_UrlPath:
  1243  		if v == nil {
  1244  			err := PrincipalValidationError{
  1245  				field:  "Identifier",
  1246  				reason: "oneof value cannot be a typed-nil",
  1247  			}
  1248  			if !all {
  1249  				return err
  1250  			}
  1251  			errors = append(errors, err)
  1252  		}
  1253  		oneofIdentifierPresent = true
  1254  
  1255  		if all {
  1256  			switch v := interface{}(m.GetUrlPath()).(type) {
  1257  			case interface{ ValidateAll() error }:
  1258  				if err := v.ValidateAll(); err != nil {
  1259  					errors = append(errors, PrincipalValidationError{
  1260  						field:  "UrlPath",
  1261  						reason: "embedded message failed validation",
  1262  						cause:  err,
  1263  					})
  1264  				}
  1265  			case interface{ Validate() error }:
  1266  				if err := v.Validate(); err != nil {
  1267  					errors = append(errors, PrincipalValidationError{
  1268  						field:  "UrlPath",
  1269  						reason: "embedded message failed validation",
  1270  						cause:  err,
  1271  					})
  1272  				}
  1273  			}
  1274  		} else if v, ok := interface{}(m.GetUrlPath()).(interface{ Validate() error }); ok {
  1275  			if err := v.Validate(); err != nil {
  1276  				return PrincipalValidationError{
  1277  					field:  "UrlPath",
  1278  					reason: "embedded message failed validation",
  1279  					cause:  err,
  1280  				}
  1281  			}
  1282  		}
  1283  
  1284  	case *Principal_Metadata:
  1285  		if v == nil {
  1286  			err := PrincipalValidationError{
  1287  				field:  "Identifier",
  1288  				reason: "oneof value cannot be a typed-nil",
  1289  			}
  1290  			if !all {
  1291  				return err
  1292  			}
  1293  			errors = append(errors, err)
  1294  		}
  1295  		oneofIdentifierPresent = true
  1296  
  1297  		if all {
  1298  			switch v := interface{}(m.GetMetadata()).(type) {
  1299  			case interface{ ValidateAll() error }:
  1300  				if err := v.ValidateAll(); err != nil {
  1301  					errors = append(errors, PrincipalValidationError{
  1302  						field:  "Metadata",
  1303  						reason: "embedded message failed validation",
  1304  						cause:  err,
  1305  					})
  1306  				}
  1307  			case interface{ Validate() error }:
  1308  				if err := v.Validate(); err != nil {
  1309  					errors = append(errors, PrincipalValidationError{
  1310  						field:  "Metadata",
  1311  						reason: "embedded message failed validation",
  1312  						cause:  err,
  1313  					})
  1314  				}
  1315  			}
  1316  		} else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok {
  1317  			if err := v.Validate(); err != nil {
  1318  				return PrincipalValidationError{
  1319  					field:  "Metadata",
  1320  					reason: "embedded message failed validation",
  1321  					cause:  err,
  1322  				}
  1323  			}
  1324  		}
  1325  
  1326  	case *Principal_NotId:
  1327  		if v == nil {
  1328  			err := PrincipalValidationError{
  1329  				field:  "Identifier",
  1330  				reason: "oneof value cannot be a typed-nil",
  1331  			}
  1332  			if !all {
  1333  				return err
  1334  			}
  1335  			errors = append(errors, err)
  1336  		}
  1337  		oneofIdentifierPresent = true
  1338  
  1339  		if all {
  1340  			switch v := interface{}(m.GetNotId()).(type) {
  1341  			case interface{ ValidateAll() error }:
  1342  				if err := v.ValidateAll(); err != nil {
  1343  					errors = append(errors, PrincipalValidationError{
  1344  						field:  "NotId",
  1345  						reason: "embedded message failed validation",
  1346  						cause:  err,
  1347  					})
  1348  				}
  1349  			case interface{ Validate() error }:
  1350  				if err := v.Validate(); err != nil {
  1351  					errors = append(errors, PrincipalValidationError{
  1352  						field:  "NotId",
  1353  						reason: "embedded message failed validation",
  1354  						cause:  err,
  1355  					})
  1356  				}
  1357  			}
  1358  		} else if v, ok := interface{}(m.GetNotId()).(interface{ Validate() error }); ok {
  1359  			if err := v.Validate(); err != nil {
  1360  				return PrincipalValidationError{
  1361  					field:  "NotId",
  1362  					reason: "embedded message failed validation",
  1363  					cause:  err,
  1364  				}
  1365  			}
  1366  		}
  1367  
  1368  	default:
  1369  		_ = v // ensures v is used
  1370  	}
  1371  	if !oneofIdentifierPresent {
  1372  		err := PrincipalValidationError{
  1373  			field:  "Identifier",
  1374  			reason: "value is required",
  1375  		}
  1376  		if !all {
  1377  			return err
  1378  		}
  1379  		errors = append(errors, err)
  1380  	}
  1381  
  1382  	if len(errors) > 0 {
  1383  		return PrincipalMultiError(errors)
  1384  	}
  1385  
  1386  	return nil
  1387  }
  1388  
  1389  // PrincipalMultiError is an error wrapping multiple validation errors returned
  1390  // by Principal.ValidateAll() if the designated constraints aren't met.
  1391  type PrincipalMultiError []error
  1392  
  1393  // Error returns a concatenation of all the error messages it wraps.
  1394  func (m PrincipalMultiError) Error() string {
  1395  	var msgs []string
  1396  	for _, err := range m {
  1397  		msgs = append(msgs, err.Error())
  1398  	}
  1399  	return strings.Join(msgs, "; ")
  1400  }
  1401  
  1402  // AllErrors returns a list of validation violation errors.
  1403  func (m PrincipalMultiError) AllErrors() []error { return m }
  1404  
  1405  // PrincipalValidationError is the validation error returned by
  1406  // Principal.Validate if the designated constraints aren't met.
  1407  type PrincipalValidationError struct {
  1408  	field  string
  1409  	reason string
  1410  	cause  error
  1411  	key    bool
  1412  }
  1413  
  1414  // Field function returns field value.
  1415  func (e PrincipalValidationError) Field() string { return e.field }
  1416  
  1417  // Reason function returns reason value.
  1418  func (e PrincipalValidationError) Reason() string { return e.reason }
  1419  
  1420  // Cause function returns cause value.
  1421  func (e PrincipalValidationError) Cause() error { return e.cause }
  1422  
  1423  // Key function returns key value.
  1424  func (e PrincipalValidationError) Key() bool { return e.key }
  1425  
  1426  // ErrorName returns error name.
  1427  func (e PrincipalValidationError) ErrorName() string { return "PrincipalValidationError" }
  1428  
  1429  // Error satisfies the builtin error interface
  1430  func (e PrincipalValidationError) Error() string {
  1431  	cause := ""
  1432  	if e.cause != nil {
  1433  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
  1434  	}
  1435  
  1436  	key := ""
  1437  	if e.key {
  1438  		key = "key for "
  1439  	}
  1440  
  1441  	return fmt.Sprintf(
  1442  		"invalid %sPrincipal.%s: %s%s",
  1443  		key,
  1444  		e.field,
  1445  		e.reason,
  1446  		cause)
  1447  }
  1448  
  1449  var _ error = PrincipalValidationError{}
  1450  
  1451  var _ interface {
  1452  	Field() string
  1453  	Reason() string
  1454  	Key() bool
  1455  	Cause() error
  1456  	ErrorName() string
  1457  } = PrincipalValidationError{}
  1458  
  1459  // Validate checks the field values on Permission_Set with the rules defined in
  1460  // the proto definition for this message. If any rules are violated, the first
  1461  // error encountered is returned, or nil if there are no violations.
  1462  func (m *Permission_Set) Validate() error {
  1463  	return m.validate(false)
  1464  }
  1465  
  1466  // ValidateAll checks the field values on Permission_Set with the rules defined
  1467  // in the proto definition for this message. If any rules are violated, the
  1468  // result is a list of violation errors wrapped in Permission_SetMultiError,
  1469  // or nil if none found.
  1470  func (m *Permission_Set) ValidateAll() error {
  1471  	return m.validate(true)
  1472  }
  1473  
  1474  func (m *Permission_Set) validate(all bool) error {
  1475  	if m == nil {
  1476  		return nil
  1477  	}
  1478  
  1479  	var errors []error
  1480  
  1481  	if len(m.GetRules()) < 1 {
  1482  		err := Permission_SetValidationError{
  1483  			field:  "Rules",
  1484  			reason: "value must contain at least 1 item(s)",
  1485  		}
  1486  		if !all {
  1487  			return err
  1488  		}
  1489  		errors = append(errors, err)
  1490  	}
  1491  
  1492  	for idx, item := range m.GetRules() {
  1493  		_, _ = idx, item
  1494  
  1495  		if all {
  1496  			switch v := interface{}(item).(type) {
  1497  			case interface{ ValidateAll() error }:
  1498  				if err := v.ValidateAll(); err != nil {
  1499  					errors = append(errors, Permission_SetValidationError{
  1500  						field:  fmt.Sprintf("Rules[%v]", idx),
  1501  						reason: "embedded message failed validation",
  1502  						cause:  err,
  1503  					})
  1504  				}
  1505  			case interface{ Validate() error }:
  1506  				if err := v.Validate(); err != nil {
  1507  					errors = append(errors, Permission_SetValidationError{
  1508  						field:  fmt.Sprintf("Rules[%v]", idx),
  1509  						reason: "embedded message failed validation",
  1510  						cause:  err,
  1511  					})
  1512  				}
  1513  			}
  1514  		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  1515  			if err := v.Validate(); err != nil {
  1516  				return Permission_SetValidationError{
  1517  					field:  fmt.Sprintf("Rules[%v]", idx),
  1518  					reason: "embedded message failed validation",
  1519  					cause:  err,
  1520  				}
  1521  			}
  1522  		}
  1523  
  1524  	}
  1525  
  1526  	if len(errors) > 0 {
  1527  		return Permission_SetMultiError(errors)
  1528  	}
  1529  
  1530  	return nil
  1531  }
  1532  
  1533  // Permission_SetMultiError is an error wrapping multiple validation errors
  1534  // returned by Permission_Set.ValidateAll() if the designated constraints
  1535  // aren't met.
  1536  type Permission_SetMultiError []error
  1537  
  1538  // Error returns a concatenation of all the error messages it wraps.
  1539  func (m Permission_SetMultiError) Error() string {
  1540  	var msgs []string
  1541  	for _, err := range m {
  1542  		msgs = append(msgs, err.Error())
  1543  	}
  1544  	return strings.Join(msgs, "; ")
  1545  }
  1546  
  1547  // AllErrors returns a list of validation violation errors.
  1548  func (m Permission_SetMultiError) AllErrors() []error { return m }
  1549  
  1550  // Permission_SetValidationError is the validation error returned by
  1551  // Permission_Set.Validate if the designated constraints aren't met.
  1552  type Permission_SetValidationError struct {
  1553  	field  string
  1554  	reason string
  1555  	cause  error
  1556  	key    bool
  1557  }
  1558  
  1559  // Field function returns field value.
  1560  func (e Permission_SetValidationError) Field() string { return e.field }
  1561  
  1562  // Reason function returns reason value.
  1563  func (e Permission_SetValidationError) Reason() string { return e.reason }
  1564  
  1565  // Cause function returns cause value.
  1566  func (e Permission_SetValidationError) Cause() error { return e.cause }
  1567  
  1568  // Key function returns key value.
  1569  func (e Permission_SetValidationError) Key() bool { return e.key }
  1570  
  1571  // ErrorName returns error name.
  1572  func (e Permission_SetValidationError) ErrorName() string { return "Permission_SetValidationError" }
  1573  
  1574  // Error satisfies the builtin error interface
  1575  func (e Permission_SetValidationError) Error() string {
  1576  	cause := ""
  1577  	if e.cause != nil {
  1578  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
  1579  	}
  1580  
  1581  	key := ""
  1582  	if e.key {
  1583  		key = "key for "
  1584  	}
  1585  
  1586  	return fmt.Sprintf(
  1587  		"invalid %sPermission_Set.%s: %s%s",
  1588  		key,
  1589  		e.field,
  1590  		e.reason,
  1591  		cause)
  1592  }
  1593  
  1594  var _ error = Permission_SetValidationError{}
  1595  
  1596  var _ interface {
  1597  	Field() string
  1598  	Reason() string
  1599  	Key() bool
  1600  	Cause() error
  1601  	ErrorName() string
  1602  } = Permission_SetValidationError{}
  1603  
  1604  // Validate checks the field values on Principal_Set with the rules defined in
  1605  // the proto definition for this message. If any rules are violated, the first
  1606  // error encountered is returned, or nil if there are no violations.
  1607  func (m *Principal_Set) Validate() error {
  1608  	return m.validate(false)
  1609  }
  1610  
  1611  // ValidateAll checks the field values on Principal_Set with the rules defined
  1612  // in the proto definition for this message. If any rules are violated, the
  1613  // result is a list of violation errors wrapped in Principal_SetMultiError, or
  1614  // nil if none found.
  1615  func (m *Principal_Set) ValidateAll() error {
  1616  	return m.validate(true)
  1617  }
  1618  
  1619  func (m *Principal_Set) validate(all bool) error {
  1620  	if m == nil {
  1621  		return nil
  1622  	}
  1623  
  1624  	var errors []error
  1625  
  1626  	if len(m.GetIds()) < 1 {
  1627  		err := Principal_SetValidationError{
  1628  			field:  "Ids",
  1629  			reason: "value must contain at least 1 item(s)",
  1630  		}
  1631  		if !all {
  1632  			return err
  1633  		}
  1634  		errors = append(errors, err)
  1635  	}
  1636  
  1637  	for idx, item := range m.GetIds() {
  1638  		_, _ = idx, item
  1639  
  1640  		if all {
  1641  			switch v := interface{}(item).(type) {
  1642  			case interface{ ValidateAll() error }:
  1643  				if err := v.ValidateAll(); err != nil {
  1644  					errors = append(errors, Principal_SetValidationError{
  1645  						field:  fmt.Sprintf("Ids[%v]", idx),
  1646  						reason: "embedded message failed validation",
  1647  						cause:  err,
  1648  					})
  1649  				}
  1650  			case interface{ Validate() error }:
  1651  				if err := v.Validate(); err != nil {
  1652  					errors = append(errors, Principal_SetValidationError{
  1653  						field:  fmt.Sprintf("Ids[%v]", idx),
  1654  						reason: "embedded message failed validation",
  1655  						cause:  err,
  1656  					})
  1657  				}
  1658  			}
  1659  		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  1660  			if err := v.Validate(); err != nil {
  1661  				return Principal_SetValidationError{
  1662  					field:  fmt.Sprintf("Ids[%v]", idx),
  1663  					reason: "embedded message failed validation",
  1664  					cause:  err,
  1665  				}
  1666  			}
  1667  		}
  1668  
  1669  	}
  1670  
  1671  	if len(errors) > 0 {
  1672  		return Principal_SetMultiError(errors)
  1673  	}
  1674  
  1675  	return nil
  1676  }
  1677  
  1678  // Principal_SetMultiError is an error wrapping multiple validation errors
  1679  // returned by Principal_Set.ValidateAll() if the designated constraints
  1680  // aren't met.
  1681  type Principal_SetMultiError []error
  1682  
  1683  // Error returns a concatenation of all the error messages it wraps.
  1684  func (m Principal_SetMultiError) Error() string {
  1685  	var msgs []string
  1686  	for _, err := range m {
  1687  		msgs = append(msgs, err.Error())
  1688  	}
  1689  	return strings.Join(msgs, "; ")
  1690  }
  1691  
  1692  // AllErrors returns a list of validation violation errors.
  1693  func (m Principal_SetMultiError) AllErrors() []error { return m }
  1694  
  1695  // Principal_SetValidationError is the validation error returned by
  1696  // Principal_Set.Validate if the designated constraints aren't met.
  1697  type Principal_SetValidationError struct {
  1698  	field  string
  1699  	reason string
  1700  	cause  error
  1701  	key    bool
  1702  }
  1703  
  1704  // Field function returns field value.
  1705  func (e Principal_SetValidationError) Field() string { return e.field }
  1706  
  1707  // Reason function returns reason value.
  1708  func (e Principal_SetValidationError) Reason() string { return e.reason }
  1709  
  1710  // Cause function returns cause value.
  1711  func (e Principal_SetValidationError) Cause() error { return e.cause }
  1712  
  1713  // Key function returns key value.
  1714  func (e Principal_SetValidationError) Key() bool { return e.key }
  1715  
  1716  // ErrorName returns error name.
  1717  func (e Principal_SetValidationError) ErrorName() string { return "Principal_SetValidationError" }
  1718  
  1719  // Error satisfies the builtin error interface
  1720  func (e Principal_SetValidationError) Error() string {
  1721  	cause := ""
  1722  	if e.cause != nil {
  1723  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
  1724  	}
  1725  
  1726  	key := ""
  1727  	if e.key {
  1728  		key = "key for "
  1729  	}
  1730  
  1731  	return fmt.Sprintf(
  1732  		"invalid %sPrincipal_Set.%s: %s%s",
  1733  		key,
  1734  		e.field,
  1735  		e.reason,
  1736  		cause)
  1737  }
  1738  
  1739  var _ error = Principal_SetValidationError{}
  1740  
  1741  var _ interface {
  1742  	Field() string
  1743  	Reason() string
  1744  	Key() bool
  1745  	Cause() error
  1746  	ErrorName() string
  1747  } = Principal_SetValidationError{}
  1748  
  1749  // Validate checks the field values on Principal_Authenticated with the rules
  1750  // defined in the proto definition for this message. If any rules are
  1751  // violated, the first error encountered is returned, or nil if there are no violations.
  1752  func (m *Principal_Authenticated) Validate() error {
  1753  	return m.validate(false)
  1754  }
  1755  
  1756  // ValidateAll checks the field values on Principal_Authenticated with the
  1757  // rules defined in the proto definition for this message. If any rules are
  1758  // violated, the result is a list of violation errors wrapped in
  1759  // Principal_AuthenticatedMultiError, or nil if none found.
  1760  func (m *Principal_Authenticated) ValidateAll() error {
  1761  	return m.validate(true)
  1762  }
  1763  
  1764  func (m *Principal_Authenticated) validate(all bool) error {
  1765  	if m == nil {
  1766  		return nil
  1767  	}
  1768  
  1769  	var errors []error
  1770  
  1771  	if all {
  1772  		switch v := interface{}(m.GetPrincipalName()).(type) {
  1773  		case interface{ ValidateAll() error }:
  1774  			if err := v.ValidateAll(); err != nil {
  1775  				errors = append(errors, Principal_AuthenticatedValidationError{
  1776  					field:  "PrincipalName",
  1777  					reason: "embedded message failed validation",
  1778  					cause:  err,
  1779  				})
  1780  			}
  1781  		case interface{ Validate() error }:
  1782  			if err := v.Validate(); err != nil {
  1783  				errors = append(errors, Principal_AuthenticatedValidationError{
  1784  					field:  "PrincipalName",
  1785  					reason: "embedded message failed validation",
  1786  					cause:  err,
  1787  				})
  1788  			}
  1789  		}
  1790  	} else if v, ok := interface{}(m.GetPrincipalName()).(interface{ Validate() error }); ok {
  1791  		if err := v.Validate(); err != nil {
  1792  			return Principal_AuthenticatedValidationError{
  1793  				field:  "PrincipalName",
  1794  				reason: "embedded message failed validation",
  1795  				cause:  err,
  1796  			}
  1797  		}
  1798  	}
  1799  
  1800  	if len(errors) > 0 {
  1801  		return Principal_AuthenticatedMultiError(errors)
  1802  	}
  1803  
  1804  	return nil
  1805  }
  1806  
  1807  // Principal_AuthenticatedMultiError is an error wrapping multiple validation
  1808  // errors returned by Principal_Authenticated.ValidateAll() if the designated
  1809  // constraints aren't met.
  1810  type Principal_AuthenticatedMultiError []error
  1811  
  1812  // Error returns a concatenation of all the error messages it wraps.
  1813  func (m Principal_AuthenticatedMultiError) Error() string {
  1814  	var msgs []string
  1815  	for _, err := range m {
  1816  		msgs = append(msgs, err.Error())
  1817  	}
  1818  	return strings.Join(msgs, "; ")
  1819  }
  1820  
  1821  // AllErrors returns a list of validation violation errors.
  1822  func (m Principal_AuthenticatedMultiError) AllErrors() []error { return m }
  1823  
  1824  // Principal_AuthenticatedValidationError is the validation error returned by
  1825  // Principal_Authenticated.Validate if the designated constraints aren't met.
  1826  type Principal_AuthenticatedValidationError struct {
  1827  	field  string
  1828  	reason string
  1829  	cause  error
  1830  	key    bool
  1831  }
  1832  
  1833  // Field function returns field value.
  1834  func (e Principal_AuthenticatedValidationError) Field() string { return e.field }
  1835  
  1836  // Reason function returns reason value.
  1837  func (e Principal_AuthenticatedValidationError) Reason() string { return e.reason }
  1838  
  1839  // Cause function returns cause value.
  1840  func (e Principal_AuthenticatedValidationError) Cause() error { return e.cause }
  1841  
  1842  // Key function returns key value.
  1843  func (e Principal_AuthenticatedValidationError) Key() bool { return e.key }
  1844  
  1845  // ErrorName returns error name.
  1846  func (e Principal_AuthenticatedValidationError) ErrorName() string {
  1847  	return "Principal_AuthenticatedValidationError"
  1848  }
  1849  
  1850  // Error satisfies the builtin error interface
  1851  func (e Principal_AuthenticatedValidationError) Error() string {
  1852  	cause := ""
  1853  	if e.cause != nil {
  1854  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
  1855  	}
  1856  
  1857  	key := ""
  1858  	if e.key {
  1859  		key = "key for "
  1860  	}
  1861  
  1862  	return fmt.Sprintf(
  1863  		"invalid %sPrincipal_Authenticated.%s: %s%s",
  1864  		key,
  1865  		e.field,
  1866  		e.reason,
  1867  		cause)
  1868  }
  1869  
  1870  var _ error = Principal_AuthenticatedValidationError{}
  1871  
  1872  var _ interface {
  1873  	Field() string
  1874  	Reason() string
  1875  	Key() bool
  1876  	Cause() error
  1877  	ErrorName() string
  1878  } = Principal_AuthenticatedValidationError{}
  1879  

View as plain text