...

Source file src/github.com/datawire/ambassador/v2/pkg/api/envoy/config/rbac/v3/rbac.pb.validate.go

Documentation: github.com/datawire/ambassador/v2/pkg/api/envoy/config/rbac/v3

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/config/rbac/v3/rbac.proto
     3  
     4  package envoy_config_rbac_v3
     5  
     6  import (
     7  	"bytes"
     8  	"errors"
     9  	"fmt"
    10  	"net"
    11  	"net/mail"
    12  	"net/url"
    13  	"regexp"
    14  	"strings"
    15  	"time"
    16  	"unicode/utf8"
    17  
    18  	"github.com/golang/protobuf/ptypes"
    19  )
    20  
    21  // ensure the imports are used
    22  var (
    23  	_ = bytes.MinRead
    24  	_ = errors.New("")
    25  	_ = fmt.Print
    26  	_ = utf8.UTFMax
    27  	_ = (*regexp.Regexp)(nil)
    28  	_ = (*strings.Reader)(nil)
    29  	_ = net.IPv4len
    30  	_ = time.Duration(0)
    31  	_ = (*url.URL)(nil)
    32  	_ = (*mail.Address)(nil)
    33  	_ = ptypes.DynamicAny{}
    34  )
    35  
    36  // Validate checks the field values on RBAC with the rules defined in the proto
    37  // definition for this message. If any rules are violated, an error is returned.
    38  func (m *RBAC) Validate() error {
    39  	if m == nil {
    40  		return nil
    41  	}
    42  
    43  	if _, ok := RBAC_Action_name[int32(m.GetAction())]; !ok {
    44  		return RBACValidationError{
    45  			field:  "Action",
    46  			reason: "value must be one of the defined enum values",
    47  		}
    48  	}
    49  
    50  	for key, val := range m.GetPolicies() {
    51  		_ = val
    52  
    53  		// no validation rules for Policies[key]
    54  
    55  		if v, ok := interface{}(val).(interface{ Validate() error }); ok {
    56  			if err := v.Validate(); err != nil {
    57  				return RBACValidationError{
    58  					field:  fmt.Sprintf("Policies[%v]", key),
    59  					reason: "embedded message failed validation",
    60  					cause:  err,
    61  				}
    62  			}
    63  		}
    64  
    65  	}
    66  
    67  	return nil
    68  }
    69  
    70  // RBACValidationError is the validation error returned by RBAC.Validate if the
    71  // designated constraints aren't met.
    72  type RBACValidationError struct {
    73  	field  string
    74  	reason string
    75  	cause  error
    76  	key    bool
    77  }
    78  
    79  // Field function returns field value.
    80  func (e RBACValidationError) Field() string { return e.field }
    81  
    82  // Reason function returns reason value.
    83  func (e RBACValidationError) Reason() string { return e.reason }
    84  
    85  // Cause function returns cause value.
    86  func (e RBACValidationError) Cause() error { return e.cause }
    87  
    88  // Key function returns key value.
    89  func (e RBACValidationError) Key() bool { return e.key }
    90  
    91  // ErrorName returns error name.
    92  func (e RBACValidationError) ErrorName() string { return "RBACValidationError" }
    93  
    94  // Error satisfies the builtin error interface
    95  func (e RBACValidationError) Error() string {
    96  	cause := ""
    97  	if e.cause != nil {
    98  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
    99  	}
   100  
   101  	key := ""
   102  	if e.key {
   103  		key = "key for "
   104  	}
   105  
   106  	return fmt.Sprintf(
   107  		"invalid %sRBAC.%s: %s%s",
   108  		key,
   109  		e.field,
   110  		e.reason,
   111  		cause)
   112  }
   113  
   114  var _ error = RBACValidationError{}
   115  
   116  var _ interface {
   117  	Field() string
   118  	Reason() string
   119  	Key() bool
   120  	Cause() error
   121  	ErrorName() string
   122  } = RBACValidationError{}
   123  
   124  // Validate checks the field values on Policy with the rules defined in the
   125  // proto definition for this message. If any rules are violated, an error is returned.
   126  func (m *Policy) Validate() error {
   127  	if m == nil {
   128  		return nil
   129  	}
   130  
   131  	if len(m.GetPermissions()) < 1 {
   132  		return PolicyValidationError{
   133  			field:  "Permissions",
   134  			reason: "value must contain at least 1 item(s)",
   135  		}
   136  	}
   137  
   138  	for idx, item := range m.GetPermissions() {
   139  		_, _ = idx, item
   140  
   141  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   142  			if err := v.Validate(); err != nil {
   143  				return PolicyValidationError{
   144  					field:  fmt.Sprintf("Permissions[%v]", idx),
   145  					reason: "embedded message failed validation",
   146  					cause:  err,
   147  				}
   148  			}
   149  		}
   150  
   151  	}
   152  
   153  	if len(m.GetPrincipals()) < 1 {
   154  		return PolicyValidationError{
   155  			field:  "Principals",
   156  			reason: "value must contain at least 1 item(s)",
   157  		}
   158  	}
   159  
   160  	for idx, item := range m.GetPrincipals() {
   161  		_, _ = idx, item
   162  
   163  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   164  			if err := v.Validate(); err != nil {
   165  				return PolicyValidationError{
   166  					field:  fmt.Sprintf("Principals[%v]", idx),
   167  					reason: "embedded message failed validation",
   168  					cause:  err,
   169  				}
   170  			}
   171  		}
   172  
   173  	}
   174  
   175  	if v, ok := interface{}(m.GetCondition()).(interface{ Validate() error }); ok {
   176  		if err := v.Validate(); err != nil {
   177  			return PolicyValidationError{
   178  				field:  "Condition",
   179  				reason: "embedded message failed validation",
   180  				cause:  err,
   181  			}
   182  		}
   183  	}
   184  
   185  	if v, ok := interface{}(m.GetCheckedCondition()).(interface{ Validate() error }); ok {
   186  		if err := v.Validate(); err != nil {
   187  			return PolicyValidationError{
   188  				field:  "CheckedCondition",
   189  				reason: "embedded message failed validation",
   190  				cause:  err,
   191  			}
   192  		}
   193  	}
   194  
   195  	return nil
   196  }
   197  
   198  // PolicyValidationError is the validation error returned by Policy.Validate if
   199  // the designated constraints aren't met.
   200  type PolicyValidationError struct {
   201  	field  string
   202  	reason string
   203  	cause  error
   204  	key    bool
   205  }
   206  
   207  // Field function returns field value.
   208  func (e PolicyValidationError) Field() string { return e.field }
   209  
   210  // Reason function returns reason value.
   211  func (e PolicyValidationError) Reason() string { return e.reason }
   212  
   213  // Cause function returns cause value.
   214  func (e PolicyValidationError) Cause() error { return e.cause }
   215  
   216  // Key function returns key value.
   217  func (e PolicyValidationError) Key() bool { return e.key }
   218  
   219  // ErrorName returns error name.
   220  func (e PolicyValidationError) ErrorName() string { return "PolicyValidationError" }
   221  
   222  // Error satisfies the builtin error interface
   223  func (e PolicyValidationError) Error() string {
   224  	cause := ""
   225  	if e.cause != nil {
   226  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   227  	}
   228  
   229  	key := ""
   230  	if e.key {
   231  		key = "key for "
   232  	}
   233  
   234  	return fmt.Sprintf(
   235  		"invalid %sPolicy.%s: %s%s",
   236  		key,
   237  		e.field,
   238  		e.reason,
   239  		cause)
   240  }
   241  
   242  var _ error = PolicyValidationError{}
   243  
   244  var _ interface {
   245  	Field() string
   246  	Reason() string
   247  	Key() bool
   248  	Cause() error
   249  	ErrorName() string
   250  } = PolicyValidationError{}
   251  
   252  // Validate checks the field values on Permission with the rules defined in the
   253  // proto definition for this message. If any rules are violated, an error is returned.
   254  func (m *Permission) Validate() error {
   255  	if m == nil {
   256  		return nil
   257  	}
   258  
   259  	switch m.Rule.(type) {
   260  
   261  	case *Permission_AndRules:
   262  
   263  		if v, ok := interface{}(m.GetAndRules()).(interface{ Validate() error }); ok {
   264  			if err := v.Validate(); err != nil {
   265  				return PermissionValidationError{
   266  					field:  "AndRules",
   267  					reason: "embedded message failed validation",
   268  					cause:  err,
   269  				}
   270  			}
   271  		}
   272  
   273  	case *Permission_OrRules:
   274  
   275  		if v, ok := interface{}(m.GetOrRules()).(interface{ Validate() error }); ok {
   276  			if err := v.Validate(); err != nil {
   277  				return PermissionValidationError{
   278  					field:  "OrRules",
   279  					reason: "embedded message failed validation",
   280  					cause:  err,
   281  				}
   282  			}
   283  		}
   284  
   285  	case *Permission_Any:
   286  
   287  		if m.GetAny() != true {
   288  			return PermissionValidationError{
   289  				field:  "Any",
   290  				reason: "value must equal true",
   291  			}
   292  		}
   293  
   294  	case *Permission_Header:
   295  
   296  		if v, ok := interface{}(m.GetHeader()).(interface{ Validate() error }); ok {
   297  			if err := v.Validate(); err != nil {
   298  				return PermissionValidationError{
   299  					field:  "Header",
   300  					reason: "embedded message failed validation",
   301  					cause:  err,
   302  				}
   303  			}
   304  		}
   305  
   306  	case *Permission_UrlPath:
   307  
   308  		if v, ok := interface{}(m.GetUrlPath()).(interface{ Validate() error }); ok {
   309  			if err := v.Validate(); err != nil {
   310  				return PermissionValidationError{
   311  					field:  "UrlPath",
   312  					reason: "embedded message failed validation",
   313  					cause:  err,
   314  				}
   315  			}
   316  		}
   317  
   318  	case *Permission_DestinationIp:
   319  
   320  		if v, ok := interface{}(m.GetDestinationIp()).(interface{ Validate() error }); ok {
   321  			if err := v.Validate(); err != nil {
   322  				return PermissionValidationError{
   323  					field:  "DestinationIp",
   324  					reason: "embedded message failed validation",
   325  					cause:  err,
   326  				}
   327  			}
   328  		}
   329  
   330  	case *Permission_DestinationPort:
   331  
   332  		if m.GetDestinationPort() > 65535 {
   333  			return PermissionValidationError{
   334  				field:  "DestinationPort",
   335  				reason: "value must be less than or equal to 65535",
   336  			}
   337  		}
   338  
   339  	case *Permission_Metadata:
   340  
   341  		if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok {
   342  			if err := v.Validate(); err != nil {
   343  				return PermissionValidationError{
   344  					field:  "Metadata",
   345  					reason: "embedded message failed validation",
   346  					cause:  err,
   347  				}
   348  			}
   349  		}
   350  
   351  	case *Permission_NotRule:
   352  
   353  		if v, ok := interface{}(m.GetNotRule()).(interface{ Validate() error }); ok {
   354  			if err := v.Validate(); err != nil {
   355  				return PermissionValidationError{
   356  					field:  "NotRule",
   357  					reason: "embedded message failed validation",
   358  					cause:  err,
   359  				}
   360  			}
   361  		}
   362  
   363  	case *Permission_RequestedServerName:
   364  
   365  		if v, ok := interface{}(m.GetRequestedServerName()).(interface{ Validate() error }); ok {
   366  			if err := v.Validate(); err != nil {
   367  				return PermissionValidationError{
   368  					field:  "RequestedServerName",
   369  					reason: "embedded message failed validation",
   370  					cause:  err,
   371  				}
   372  			}
   373  		}
   374  
   375  	default:
   376  		return PermissionValidationError{
   377  			field:  "Rule",
   378  			reason: "value is required",
   379  		}
   380  
   381  	}
   382  
   383  	return nil
   384  }
   385  
   386  // PermissionValidationError is the validation error returned by
   387  // Permission.Validate if the designated constraints aren't met.
   388  type PermissionValidationError struct {
   389  	field  string
   390  	reason string
   391  	cause  error
   392  	key    bool
   393  }
   394  
   395  // Field function returns field value.
   396  func (e PermissionValidationError) Field() string { return e.field }
   397  
   398  // Reason function returns reason value.
   399  func (e PermissionValidationError) Reason() string { return e.reason }
   400  
   401  // Cause function returns cause value.
   402  func (e PermissionValidationError) Cause() error { return e.cause }
   403  
   404  // Key function returns key value.
   405  func (e PermissionValidationError) Key() bool { return e.key }
   406  
   407  // ErrorName returns error name.
   408  func (e PermissionValidationError) ErrorName() string { return "PermissionValidationError" }
   409  
   410  // Error satisfies the builtin error interface
   411  func (e PermissionValidationError) Error() string {
   412  	cause := ""
   413  	if e.cause != nil {
   414  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   415  	}
   416  
   417  	key := ""
   418  	if e.key {
   419  		key = "key for "
   420  	}
   421  
   422  	return fmt.Sprintf(
   423  		"invalid %sPermission.%s: %s%s",
   424  		key,
   425  		e.field,
   426  		e.reason,
   427  		cause)
   428  }
   429  
   430  var _ error = PermissionValidationError{}
   431  
   432  var _ interface {
   433  	Field() string
   434  	Reason() string
   435  	Key() bool
   436  	Cause() error
   437  	ErrorName() string
   438  } = PermissionValidationError{}
   439  
   440  // Validate checks the field values on Principal with the rules defined in the
   441  // proto definition for this message. If any rules are violated, an error is returned.
   442  func (m *Principal) Validate() error {
   443  	if m == nil {
   444  		return nil
   445  	}
   446  
   447  	switch m.Identifier.(type) {
   448  
   449  	case *Principal_AndIds:
   450  
   451  		if v, ok := interface{}(m.GetAndIds()).(interface{ Validate() error }); ok {
   452  			if err := v.Validate(); err != nil {
   453  				return PrincipalValidationError{
   454  					field:  "AndIds",
   455  					reason: "embedded message failed validation",
   456  					cause:  err,
   457  				}
   458  			}
   459  		}
   460  
   461  	case *Principal_OrIds:
   462  
   463  		if v, ok := interface{}(m.GetOrIds()).(interface{ Validate() error }); ok {
   464  			if err := v.Validate(); err != nil {
   465  				return PrincipalValidationError{
   466  					field:  "OrIds",
   467  					reason: "embedded message failed validation",
   468  					cause:  err,
   469  				}
   470  			}
   471  		}
   472  
   473  	case *Principal_Any:
   474  
   475  		if m.GetAny() != true {
   476  			return PrincipalValidationError{
   477  				field:  "Any",
   478  				reason: "value must equal true",
   479  			}
   480  		}
   481  
   482  	case *Principal_Authenticated_:
   483  
   484  		if v, ok := interface{}(m.GetAuthenticated()).(interface{ Validate() error }); ok {
   485  			if err := v.Validate(); err != nil {
   486  				return PrincipalValidationError{
   487  					field:  "Authenticated",
   488  					reason: "embedded message failed validation",
   489  					cause:  err,
   490  				}
   491  			}
   492  		}
   493  
   494  	case *Principal_SourceIp:
   495  
   496  		if v, ok := interface{}(m.GetSourceIp()).(interface{ Validate() error }); ok {
   497  			if err := v.Validate(); err != nil {
   498  				return PrincipalValidationError{
   499  					field:  "SourceIp",
   500  					reason: "embedded message failed validation",
   501  					cause:  err,
   502  				}
   503  			}
   504  		}
   505  
   506  	case *Principal_DirectRemoteIp:
   507  
   508  		if v, ok := interface{}(m.GetDirectRemoteIp()).(interface{ Validate() error }); ok {
   509  			if err := v.Validate(); err != nil {
   510  				return PrincipalValidationError{
   511  					field:  "DirectRemoteIp",
   512  					reason: "embedded message failed validation",
   513  					cause:  err,
   514  				}
   515  			}
   516  		}
   517  
   518  	case *Principal_RemoteIp:
   519  
   520  		if v, ok := interface{}(m.GetRemoteIp()).(interface{ Validate() error }); ok {
   521  			if err := v.Validate(); err != nil {
   522  				return PrincipalValidationError{
   523  					field:  "RemoteIp",
   524  					reason: "embedded message failed validation",
   525  					cause:  err,
   526  				}
   527  			}
   528  		}
   529  
   530  	case *Principal_Header:
   531  
   532  		if v, ok := interface{}(m.GetHeader()).(interface{ Validate() error }); ok {
   533  			if err := v.Validate(); err != nil {
   534  				return PrincipalValidationError{
   535  					field:  "Header",
   536  					reason: "embedded message failed validation",
   537  					cause:  err,
   538  				}
   539  			}
   540  		}
   541  
   542  	case *Principal_UrlPath:
   543  
   544  		if v, ok := interface{}(m.GetUrlPath()).(interface{ Validate() error }); ok {
   545  			if err := v.Validate(); err != nil {
   546  				return PrincipalValidationError{
   547  					field:  "UrlPath",
   548  					reason: "embedded message failed validation",
   549  					cause:  err,
   550  				}
   551  			}
   552  		}
   553  
   554  	case *Principal_Metadata:
   555  
   556  		if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok {
   557  			if err := v.Validate(); err != nil {
   558  				return PrincipalValidationError{
   559  					field:  "Metadata",
   560  					reason: "embedded message failed validation",
   561  					cause:  err,
   562  				}
   563  			}
   564  		}
   565  
   566  	case *Principal_NotId:
   567  
   568  		if v, ok := interface{}(m.GetNotId()).(interface{ Validate() error }); ok {
   569  			if err := v.Validate(); err != nil {
   570  				return PrincipalValidationError{
   571  					field:  "NotId",
   572  					reason: "embedded message failed validation",
   573  					cause:  err,
   574  				}
   575  			}
   576  		}
   577  
   578  	default:
   579  		return PrincipalValidationError{
   580  			field:  "Identifier",
   581  			reason: "value is required",
   582  		}
   583  
   584  	}
   585  
   586  	return nil
   587  }
   588  
   589  // PrincipalValidationError is the validation error returned by
   590  // Principal.Validate if the designated constraints aren't met.
   591  type PrincipalValidationError struct {
   592  	field  string
   593  	reason string
   594  	cause  error
   595  	key    bool
   596  }
   597  
   598  // Field function returns field value.
   599  func (e PrincipalValidationError) Field() string { return e.field }
   600  
   601  // Reason function returns reason value.
   602  func (e PrincipalValidationError) Reason() string { return e.reason }
   603  
   604  // Cause function returns cause value.
   605  func (e PrincipalValidationError) Cause() error { return e.cause }
   606  
   607  // Key function returns key value.
   608  func (e PrincipalValidationError) Key() bool { return e.key }
   609  
   610  // ErrorName returns error name.
   611  func (e PrincipalValidationError) ErrorName() string { return "PrincipalValidationError" }
   612  
   613  // Error satisfies the builtin error interface
   614  func (e PrincipalValidationError) Error() string {
   615  	cause := ""
   616  	if e.cause != nil {
   617  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   618  	}
   619  
   620  	key := ""
   621  	if e.key {
   622  		key = "key for "
   623  	}
   624  
   625  	return fmt.Sprintf(
   626  		"invalid %sPrincipal.%s: %s%s",
   627  		key,
   628  		e.field,
   629  		e.reason,
   630  		cause)
   631  }
   632  
   633  var _ error = PrincipalValidationError{}
   634  
   635  var _ interface {
   636  	Field() string
   637  	Reason() string
   638  	Key() bool
   639  	Cause() error
   640  	ErrorName() string
   641  } = PrincipalValidationError{}
   642  
   643  // Validate checks the field values on Permission_Set with the rules defined in
   644  // the proto definition for this message. If any rules are violated, an error
   645  // is returned.
   646  func (m *Permission_Set) Validate() error {
   647  	if m == nil {
   648  		return nil
   649  	}
   650  
   651  	if len(m.GetRules()) < 1 {
   652  		return Permission_SetValidationError{
   653  			field:  "Rules",
   654  			reason: "value must contain at least 1 item(s)",
   655  		}
   656  	}
   657  
   658  	for idx, item := range m.GetRules() {
   659  		_, _ = idx, item
   660  
   661  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   662  			if err := v.Validate(); err != nil {
   663  				return Permission_SetValidationError{
   664  					field:  fmt.Sprintf("Rules[%v]", idx),
   665  					reason: "embedded message failed validation",
   666  					cause:  err,
   667  				}
   668  			}
   669  		}
   670  
   671  	}
   672  
   673  	return nil
   674  }
   675  
   676  // Permission_SetValidationError is the validation error returned by
   677  // Permission_Set.Validate if the designated constraints aren't met.
   678  type Permission_SetValidationError struct {
   679  	field  string
   680  	reason string
   681  	cause  error
   682  	key    bool
   683  }
   684  
   685  // Field function returns field value.
   686  func (e Permission_SetValidationError) Field() string { return e.field }
   687  
   688  // Reason function returns reason value.
   689  func (e Permission_SetValidationError) Reason() string { return e.reason }
   690  
   691  // Cause function returns cause value.
   692  func (e Permission_SetValidationError) Cause() error { return e.cause }
   693  
   694  // Key function returns key value.
   695  func (e Permission_SetValidationError) Key() bool { return e.key }
   696  
   697  // ErrorName returns error name.
   698  func (e Permission_SetValidationError) ErrorName() string { return "Permission_SetValidationError" }
   699  
   700  // Error satisfies the builtin error interface
   701  func (e Permission_SetValidationError) Error() string {
   702  	cause := ""
   703  	if e.cause != nil {
   704  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   705  	}
   706  
   707  	key := ""
   708  	if e.key {
   709  		key = "key for "
   710  	}
   711  
   712  	return fmt.Sprintf(
   713  		"invalid %sPermission_Set.%s: %s%s",
   714  		key,
   715  		e.field,
   716  		e.reason,
   717  		cause)
   718  }
   719  
   720  var _ error = Permission_SetValidationError{}
   721  
   722  var _ interface {
   723  	Field() string
   724  	Reason() string
   725  	Key() bool
   726  	Cause() error
   727  	ErrorName() string
   728  } = Permission_SetValidationError{}
   729  
   730  // Validate checks the field values on Principal_Set with the rules defined in
   731  // the proto definition for this message. If any rules are violated, an error
   732  // is returned.
   733  func (m *Principal_Set) Validate() error {
   734  	if m == nil {
   735  		return nil
   736  	}
   737  
   738  	if len(m.GetIds()) < 1 {
   739  		return Principal_SetValidationError{
   740  			field:  "Ids",
   741  			reason: "value must contain at least 1 item(s)",
   742  		}
   743  	}
   744  
   745  	for idx, item := range m.GetIds() {
   746  		_, _ = idx, item
   747  
   748  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   749  			if err := v.Validate(); err != nil {
   750  				return Principal_SetValidationError{
   751  					field:  fmt.Sprintf("Ids[%v]", idx),
   752  					reason: "embedded message failed validation",
   753  					cause:  err,
   754  				}
   755  			}
   756  		}
   757  
   758  	}
   759  
   760  	return nil
   761  }
   762  
   763  // Principal_SetValidationError is the validation error returned by
   764  // Principal_Set.Validate if the designated constraints aren't met.
   765  type Principal_SetValidationError struct {
   766  	field  string
   767  	reason string
   768  	cause  error
   769  	key    bool
   770  }
   771  
   772  // Field function returns field value.
   773  func (e Principal_SetValidationError) Field() string { return e.field }
   774  
   775  // Reason function returns reason value.
   776  func (e Principal_SetValidationError) Reason() string { return e.reason }
   777  
   778  // Cause function returns cause value.
   779  func (e Principal_SetValidationError) Cause() error { return e.cause }
   780  
   781  // Key function returns key value.
   782  func (e Principal_SetValidationError) Key() bool { return e.key }
   783  
   784  // ErrorName returns error name.
   785  func (e Principal_SetValidationError) ErrorName() string { return "Principal_SetValidationError" }
   786  
   787  // Error satisfies the builtin error interface
   788  func (e Principal_SetValidationError) Error() string {
   789  	cause := ""
   790  	if e.cause != nil {
   791  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   792  	}
   793  
   794  	key := ""
   795  	if e.key {
   796  		key = "key for "
   797  	}
   798  
   799  	return fmt.Sprintf(
   800  		"invalid %sPrincipal_Set.%s: %s%s",
   801  		key,
   802  		e.field,
   803  		e.reason,
   804  		cause)
   805  }
   806  
   807  var _ error = Principal_SetValidationError{}
   808  
   809  var _ interface {
   810  	Field() string
   811  	Reason() string
   812  	Key() bool
   813  	Cause() error
   814  	ErrorName() string
   815  } = Principal_SetValidationError{}
   816  
   817  // Validate checks the field values on Principal_Authenticated with the rules
   818  // defined in the proto definition for this message. If any rules are
   819  // violated, an error is returned.
   820  func (m *Principal_Authenticated) Validate() error {
   821  	if m == nil {
   822  		return nil
   823  	}
   824  
   825  	if v, ok := interface{}(m.GetPrincipalName()).(interface{ Validate() error }); ok {
   826  		if err := v.Validate(); err != nil {
   827  			return Principal_AuthenticatedValidationError{
   828  				field:  "PrincipalName",
   829  				reason: "embedded message failed validation",
   830  				cause:  err,
   831  			}
   832  		}
   833  	}
   834  
   835  	return nil
   836  }
   837  
   838  // Principal_AuthenticatedValidationError is the validation error returned by
   839  // Principal_Authenticated.Validate if the designated constraints aren't met.
   840  type Principal_AuthenticatedValidationError struct {
   841  	field  string
   842  	reason string
   843  	cause  error
   844  	key    bool
   845  }
   846  
   847  // Field function returns field value.
   848  func (e Principal_AuthenticatedValidationError) Field() string { return e.field }
   849  
   850  // Reason function returns reason value.
   851  func (e Principal_AuthenticatedValidationError) Reason() string { return e.reason }
   852  
   853  // Cause function returns cause value.
   854  func (e Principal_AuthenticatedValidationError) Cause() error { return e.cause }
   855  
   856  // Key function returns key value.
   857  func (e Principal_AuthenticatedValidationError) Key() bool { return e.key }
   858  
   859  // ErrorName returns error name.
   860  func (e Principal_AuthenticatedValidationError) ErrorName() string {
   861  	return "Principal_AuthenticatedValidationError"
   862  }
   863  
   864  // Error satisfies the builtin error interface
   865  func (e Principal_AuthenticatedValidationError) Error() string {
   866  	cause := ""
   867  	if e.cause != nil {
   868  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   869  	}
   870  
   871  	key := ""
   872  	if e.key {
   873  		key = "key for "
   874  	}
   875  
   876  	return fmt.Sprintf(
   877  		"invalid %sPrincipal_Authenticated.%s: %s%s",
   878  		key,
   879  		e.field,
   880  		e.reason,
   881  		cause)
   882  }
   883  
   884  var _ error = Principal_AuthenticatedValidationError{}
   885  
   886  var _ interface {
   887  	Field() string
   888  	Reason() string
   889  	Key() bool
   890  	Cause() error
   891  	ErrorName() string
   892  } = Principal_AuthenticatedValidationError{}
   893  

View as plain text