| 1 |
//go:build !disable_pgv |
| 2 |
// Code generated by protoc-gen-validate. DO NOT EDIT. |
| 3 |
// source: envoy/config/rbac/v3/rbac.proto |
| 4 |
|
| 5 |
package rbacv3 |
| 6 |
|
| 7 |
import ( |
| 8 |
"bytes" |
| 9 |
"errors" |
| 10 |
"fmt" |
| 11 |
"net" |
| 12 |
"net/mail" |
| 13 |
"net/url" |
| 14 |
"regexp" |
| 15 |
"sort" |
| 16 |
"strings" |
| 17 |
"time" |
| 18 |
"unicode/utf8" |
| 19 |
|
| 20 |
"google.golang.org/protobuf/types/known/anypb" |
| 21 |
) |
| 22 |
|
| 23 |
// ensure the imports are used |
| 24 |
var ( |
| 25 |
_ = bytes.MinRead |
| 26 |
_ = errors.New("") |
| 27 |
_ = fmt.Print |
| 28 |
_ = utf8.UTFMax |
| 29 |
_ = (*regexp.Regexp)(nil) |
| 30 |
_ = (*strings.Reader)(nil) |
| 31 |
_ = net.IPv4len |
| 32 |
_ = time.Duration(0) |
| 33 |
_ = (*url.URL)(nil) |
| 34 |
_ = (*mail.Address)(nil) |
| 35 |
_ = anypb.Any{} |
| 36 |
_ = sort.Sort |
| 37 |
) |
| 38 |
|
| 39 |
// Validate checks the field values on RBAC with the rules defined in the proto |
| 40 |
// definition for this message. If any rules are violated, the first error |
| 41 |
// encountered is returned, or nil if there are no violations. |
| 42 |
func (m *RBAC) Validate() error { |
| 43 |
return m.validate(false) |
| 44 |
} |
| 45 |
|
| 46 |
// ValidateAll checks the field values on RBAC with the rules defined in the |
| 47 |
// proto definition for this message. If any rules are violated, the result is |
| 48 |
// a list of violation errors wrapped in RBACMultiError, or nil if none found. |
| 49 |
func (m *RBAC) ValidateAll() error { |
| 50 |
return m.validate(true) |
| 51 |
} |
| 52 |
|
| 53 |
func (m *RBAC) validate(all bool) error { |
| 54 |
if m == nil { |
| 55 |
return nil |
| 56 |
} |
| 57 |
|
| 58 |
var errors []error |
| 59 |
|
| 60 |
if _, ok := RBAC_Action_name[int32(m.GetAction())]; !ok { |
| 61 |
err := RBACValidationError{ |
| 62 |
field: "Action", |
| 63 |
reason: "value must be one of the defined enum values", |
| 64 |
} |
| 65 |
if !all { |
| 66 |
return err |
| 67 |
} |
| 68 |
errors = append(errors, err) |
| 69 |
} |
| 70 |
|
| 71 |
{ |
| 72 |
sorted_keys := make([]string, len(m.GetPolicies())) |
| 73 |
i := 0 |
| 74 |
for key := range m.GetPolicies() { |
| 75 |
sorted_keys[i] = key |
| 76 |
i++ |
| 77 |
} |
| 78 |
sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) |
| 79 |
for _, key := range sorted_keys { |
| 80 |
val := m.GetPolicies()[key] |
| 81 |
_ = val |
| 82 |
|
| 83 |
// no validation rules for Policies[key] |
| 84 |
|
| 85 |
if all { |
| 86 |
switch v := interface{}(val).(type) { |
| 87 |
case interface{ ValidateAll() error }: |
| 88 |
if err := v.ValidateAll(); err != nil { |
| 89 |
errors = append(errors, RBACValidationError{ |
| 90 |
field: fmt.Sprintf("Policies[%v]", key), |
| 91 |
reason: "embedded message failed validation", |
| 92 |
cause: err, |
| 93 |
}) |
| 94 |
} |
| 95 |
case interface{ Validate() error }: |
| 96 |
if err := v.Validate(); err != nil { |
| 97 |
errors = append(errors, RBACValidationError{ |
| 98 |
field: fmt.Sprintf("Policies[%v]", key), |
| 99 |
reason: "embedded message failed validation", |
| 100 |
cause: err, |
| 101 |
}) |
| 102 |
} |
| 103 |
} |
| 104 |
} else if v, ok := interface{}(val).(interface{ Validate() error }); ok { |
| 105 |
if err := v.Validate(); err != nil { |
| 106 |
return RBACValidationError{ |
| 107 |
field: fmt.Sprintf("Policies[%v]", key), |
| 108 |
reason: "embedded message failed validation", |
| 109 |
cause: err, |
| 110 |
} |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
if all { |
| 118 |
switch v := interface{}(m.GetAuditLoggingOptions()).(type) { |
| 119 |
case interface{ ValidateAll() error }: |
| 120 |
if err := v.ValidateAll(); err != nil { |
| 121 |
errors = append(errors, RBACValidationError{ |
| 122 |
field: "AuditLoggingOptions", |
| 123 |
reason: "embedded message failed validation", |
| 124 |
cause: err, |
| 125 |
}) |
| 126 |
} |
| 127 |
case interface{ Validate() error }: |
| 128 |
if err := v.Validate(); err != nil { |
| 129 |
errors = append(errors, RBACValidationError{ |
| 130 |
field: "AuditLoggingOptions", |
| 131 |
reason: "embedded message failed validation", |
| 132 |
cause: err, |
| 133 |
}) |
| 134 |
} |
| 135 |
} |
| 136 |
} else if v, ok := interface{}(m.GetAuditLoggingOptions()).(interface{ Validate() error }); ok { |
| 137 |
if err := v.Validate(); err != nil { |
| 138 |
return RBACValidationError{ |
| 139 |
field: "AuditLoggingOptions", |
| 140 |
reason: "embedded message failed validation", |
| 141 |
cause: err, |
| 142 |
} |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
if len(errors) > 0 { |
| 147 |
return RBACMultiError(errors) |
| 148 |
} |
| 149 |
|
| 150 |
return nil |
| 151 |
} |
| 152 |
|
| 153 |
// RBACMultiError is an error wrapping multiple validation errors returned by |
| 154 |
// RBAC.ValidateAll() if the designated constraints aren't met. |
| 155 |
type RBACMultiError []error |
| 156 |
|
| 157 |
// Error returns a concatenation of all the error messages it wraps. |
| 158 |
func (m RBACMultiError) Error() string { |
| 159 |
var msgs []string |
| 160 |
for _, err := range m { |
| 161 |
msgs = append(msgs, err.Error()) |
| 162 |
} |
| 163 |
return strings.Join(msgs, "; ") |
| 164 |
} |
| 165 |
|
| 166 |
// AllErrors returns a list of validation violation errors. |
| 167 |
func (m RBACMultiError) AllErrors() []error { return m } |
| 168 |
|
| 169 |
// RBACValidationError is the validation error returned by RBAC.Validate if the |
| 170 |
// designated constraints aren't met. |
| 171 |
type RBACValidationError struct { |
| 172 |
field string |
| 173 |
reason string |
| 174 |
cause error |
| 175 |
key bool |
| 176 |
} |
| 177 |
|
| 178 |
// Field function returns field value. |
| 179 |
func (e RBACValidationError) Field() string { return e.field } |
| 180 |
|
| 181 |
// Reason function returns reason value. |
| 182 |
func (e RBACValidationError) Reason() string { return e.reason } |
| 183 |
|
| 184 |
// Cause function returns cause value. |
| 185 |
func (e RBACValidationError) Cause() error { return e.cause } |
| 186 |
|
| 187 |
// Key function returns key value. |
| 188 |
func (e RBACValidationError) Key() bool { return e.key } |
| 189 |
|
| 190 |
// ErrorName returns error name. |
| 191 |
func (e RBACValidationError) ErrorName() string { return "RBACValidationError" } |
| 192 |
|
| 193 |
// Error satisfies the builtin error interface |
| 194 |
func (e RBACValidationError) Error() string { |
| 195 |
cause := "" |
| 196 |
if e.cause != nil { |
| 197 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 198 |
} |
| 199 |
|
| 200 |
key := "" |
| 201 |
if e.key { |
| 202 |
key = "key for " |
| 203 |
} |
| 204 |
|
| 205 |
return fmt.Sprintf( |
| 206 |
"invalid %sRBAC.%s: %s%s", |
| 207 |
key, |
| 208 |
e.field, |
| 209 |
e.reason, |
| 210 |
cause) |
| 211 |
} |
| 212 |
|
| 213 |
var _ error = RBACValidationError{} |
| 214 |
|
| 215 |
var _ interface { |
| 216 |
Field() string |
| 217 |
Reason() string |
| 218 |
Key() bool |
| 219 |
Cause() error |
| 220 |
ErrorName() string |
| 221 |
} = RBACValidationError{} |
| 222 |
|
| 223 |
// Validate checks the field values on Policy with the rules defined in the |
| 224 |
// proto definition for this message. If any rules are violated, the first |
| 225 |
// error encountered is returned, or nil if there are no violations. |
| 226 |
func (m *Policy) Validate() error { |
| 227 |
return m.validate(false) |
| 228 |
} |
| 229 |
|
| 230 |
// ValidateAll checks the field values on Policy with the rules defined in the |
| 231 |
// proto definition for this message. If any rules are violated, the result is |
| 232 |
// a list of violation errors wrapped in PolicyMultiError, or nil if none found. |
| 233 |
func (m *Policy) ValidateAll() error { |
| 234 |
return m.validate(true) |
| 235 |
} |
| 236 |
|
| 237 |
func (m *Policy) validate(all bool) error { |
| 238 |
if m == nil { |
| 239 |
return nil |
| 240 |
} |
| 241 |
|
| 242 |
var errors []error |
| 243 |
|
| 244 |
if len(m.GetPermissions()) < 1 { |
| 245 |
err := PolicyValidationError{ |
| 246 |
field: "Permissions", |
| 247 |
reason: "value must contain at least 1 item(s)", |
| 248 |
} |
| 249 |
if !all { |
| 250 |
return err |
| 251 |
} |
| 252 |
errors = append(errors, err) |
| 253 |
} |
| 254 |
|
| 255 |
for idx, item := range m.GetPermissions() { |
| 256 |
_, _ = idx, item |
| 257 |
|
| 258 |
if all { |
| 259 |
switch v := interface{}(item).(type) { |
| 260 |
case interface{ ValidateAll() error }: |
| 261 |
if err := v.ValidateAll(); err != nil { |
| 262 |
errors = append(errors, PolicyValidationError{ |
| 263 |
field: fmt.Sprintf("Permissions[%v]", idx), |
| 264 |
reason: "embedded message failed validation", |
| 265 |
cause: err, |
| 266 |
}) |
| 267 |
} |
| 268 |
case interface{ Validate() error }: |
| 269 |
if err := v.Validate(); err != nil { |
| 270 |
errors = append(errors, PolicyValidationError{ |
| 271 |
field: fmt.Sprintf("Permissions[%v]", idx), |
| 272 |
reason: "embedded message failed validation", |
| 273 |
cause: err, |
| 274 |
}) |
| 275 |
} |
| 276 |
} |
| 277 |
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
| 278 |
if err := v.Validate(); err != nil { |
| 279 |
return PolicyValidationError{ |
| 280 |
field: fmt.Sprintf("Permissions[%v]", idx), |
| 281 |
reason: "embedded message failed validation", |
| 282 |
cause: err, |
| 283 |
} |
| 284 |
} |
| 285 |
} |
| 286 |
|
| 287 |
} |
| 288 |
|
| 289 |
if len(m.GetPrincipals()) < 1 { |
| 290 |
err := PolicyValidationError{ |
| 291 |
field: "Principals", |
| 292 |
reason: "value must contain at least 1 item(s)", |
| 293 |
} |
| 294 |
if !all { |
| 295 |
return err |
| 296 |
} |
| 297 |
errors = append(errors, err) |
| 298 |
} |
| 299 |
|
| 300 |
for idx, item := range m.GetPrincipals() { |
| 301 |
_, _ = idx, item |
| 302 |
|
| 303 |
if all { |
| 304 |
switch v := interface{}(item).(type) { |
| 305 |
case interface{ ValidateAll() error }: |
| 306 |
if err := v.ValidateAll(); err != nil { |
| 307 |
errors = append(errors, PolicyValidationError{ |
| 308 |
field: fmt.Sprintf("Principals[%v]", idx), |
| 309 |
reason: "embedded message failed validation", |
| 310 |
cause: err, |
| 311 |
}) |
| 312 |
} |
| 313 |
case interface{ Validate() error }: |
| 314 |
if err := v.Validate(); err != nil { |
| 315 |
errors = append(errors, PolicyValidationError{ |
| 316 |
field: fmt.Sprintf("Principals[%v]", idx), |
| 317 |
reason: "embedded message failed validation", |
| 318 |
cause: err, |
| 319 |
}) |
| 320 |
} |
| 321 |
} |
| 322 |
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
| 323 |
if err := v.Validate(); err != nil { |
| 324 |
return PolicyValidationError{ |
| 325 |
field: fmt.Sprintf("Principals[%v]", idx), |
| 326 |
reason: "embedded message failed validation", |
| 327 |
cause: err, |
| 328 |
} |
| 329 |
} |
| 330 |
} |
| 331 |
|
| 332 |
} |
| 333 |
|
| 334 |
if all { |
| 335 |
switch v := interface{}(m.GetCondition()).(type) { |
| 336 |
case interface{ ValidateAll() error }: |
| 337 |
if err := v.ValidateAll(); err != nil { |
| 338 |
errors = append(errors, PolicyValidationError{ |
| 339 |
field: "Condition", |
| 340 |
reason: "embedded message failed validation", |
| 341 |
cause: err, |
| 342 |
}) |
| 343 |
} |
| 344 |
case interface{ Validate() error }: |
| 345 |
if err := v.Validate(); err != nil { |
| 346 |
errors = append(errors, PolicyValidationError{ |
| 347 |
field: "Condition", |
| 348 |
reason: "embedded message failed validation", |
| 349 |
cause: err, |
| 350 |
}) |
| 351 |
} |
| 352 |
} |
| 353 |
} else if v, ok := interface{}(m.GetCondition()).(interface{ Validate() error }); ok { |
| 354 |
if err := v.Validate(); err != nil { |
| 355 |
return PolicyValidationError{ |
| 356 |
field: "Condition", |
| 357 |
reason: "embedded message failed validation", |
| 358 |
cause: err, |
| 359 |
} |
| 360 |
} |
| 361 |
} |
| 362 |
|
| 363 |
if all { |
| 364 |
switch v := interface{}(m.GetCheckedCondition()).(type) { |
| 365 |
case interface{ ValidateAll() error }: |
| 366 |
if err := v.ValidateAll(); err != nil { |
| 367 |
errors = append(errors, PolicyValidationError{ |
| 368 |
field: "CheckedCondition", |
| 369 |
reason: "embedded message failed validation", |
| 370 |
cause: err, |
| 371 |
}) |
| 372 |
} |
| 373 |
case interface{ Validate() error }: |
| 374 |
if err := v.Validate(); err != nil { |
| 375 |
errors = append(errors, PolicyValidationError{ |
| 376 |
field: "CheckedCondition", |
| 377 |
reason: "embedded message failed validation", |
| 378 |
cause: err, |
| 379 |
}) |
| 380 |
} |
| 381 |
} |
| 382 |
} else if v, ok := interface{}(m.GetCheckedCondition()).(interface{ Validate() error }); ok { |
| 383 |
if err := v.Validate(); err != nil { |
| 384 |
return PolicyValidationError{ |
| 385 |
field: "CheckedCondition", |
| 386 |
reason: "embedded message failed validation", |
| 387 |
cause: err, |
| 388 |
} |
| 389 |
} |
| 390 |
} |
| 391 |
|
| 392 |
if len(errors) > 0 { |
| 393 |
return PolicyMultiError(errors) |
| 394 |
} |
| 395 |
|
| 396 |
return nil |
| 397 |
} |
| 398 |
|
| 399 |
// PolicyMultiError is an error wrapping multiple validation errors returned by |
| 400 |
// Policy.ValidateAll() if the designated constraints aren't met. |
| 401 |
type PolicyMultiError []error |
| 402 |
|
| 403 |
// Error returns a concatenation of all the error messages it wraps. |
| 404 |
func (m PolicyMultiError) Error() string { |
| 405 |
var msgs []string |
| 406 |
for _, err := range m { |
| 407 |
msgs = append(msgs, err.Error()) |
| 408 |
} |
| 409 |
return strings.Join(msgs, "; ") |
| 410 |
} |
| 411 |
|
| 412 |
// AllErrors returns a list of validation violation errors. |
| 413 |
func (m PolicyMultiError) AllErrors() []error { return m } |
| 414 |
|
| 415 |
// PolicyValidationError is the validation error returned by Policy.Validate if |
| 416 |
// the designated constraints aren't met. |
| 417 |
type PolicyValidationError struct { |
| 418 |
field string |
| 419 |
reason string |
| 420 |
cause error |
| 421 |
key bool |
| 422 |
} |
| 423 |
|
| 424 |
// Field function returns field value. |
| 425 |
func (e PolicyValidationError) Field() string { return e.field } |
| 426 |
|
| 427 |
// Reason function returns reason value. |
| 428 |
func (e PolicyValidationError) Reason() string { return e.reason } |
| 429 |
|
| 430 |
// Cause function returns cause value. |
| 431 |
func (e PolicyValidationError) Cause() error { return e.cause } |
| 432 |
|
| 433 |
// Key function returns key value. |
| 434 |
func (e PolicyValidationError) Key() bool { return e.key } |
| 435 |
|
| 436 |
// ErrorName returns error name. |
| 437 |
func (e PolicyValidationError) ErrorName() string { return "PolicyValidationError" } |
| 438 |
|
| 439 |
// Error satisfies the builtin error interface |
| 440 |
func (e PolicyValidationError) Error() string { |
| 441 |
cause := "" |
| 442 |
if e.cause != nil { |
| 443 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 444 |
} |
| 445 |
|
| 446 |
key := "" |
| 447 |
if e.key { |
| 448 |
key = "key for " |
| 449 |
} |
| 450 |
|
| 451 |
return fmt.Sprintf( |
| 452 |
"invalid %sPolicy.%s: %s%s", |
| 453 |
key, |
| 454 |
e.field, |
| 455 |
e.reason, |
| 456 |
cause) |
| 457 |
} |
| 458 |
|
| 459 |
var _ error = PolicyValidationError{} |
| 460 |
|
| 461 |
var _ interface { |
| 462 |
Field() string |
| 463 |
Reason() string |
| 464 |
Key() bool |
| 465 |
Cause() error |
| 466 |
ErrorName() string |
| 467 |
} = PolicyValidationError{} |
| 468 |
|
| 469 |
// Validate checks the field values on SourcedMetadata with the rules defined |
| 470 |
// in the proto definition for this message. If any rules are violated, the |
| 471 |
// first error encountered is returned, or nil if there are no violations. |
| 472 |
func (m *SourcedMetadata) Validate() error { |
| 473 |
return m.validate(false) |
| 474 |
} |
| 475 |
|
| 476 |
// ValidateAll checks the field values on SourcedMetadata with the rules |
| 477 |
// defined in the proto definition for this message. If any rules are |
| 478 |
// violated, the result is a list of violation errors wrapped in |
| 479 |
// SourcedMetadataMultiError, or nil if none found. |
| 480 |
func (m *SourcedMetadata) ValidateAll() error { |
| 481 |
return m.validate(true) |
| 482 |
} |
| 483 |
|
| 484 |
func (m *SourcedMetadata) validate(all bool) error { |
| 485 |
if m == nil { |
| 486 |
return nil |
| 487 |
} |
| 488 |
|
| 489 |
var errors []error |
| 490 |
|
| 491 |
if m.GetMetadataMatcher() == nil { |
| 492 |
err := SourcedMetadataValidationError{ |
| 493 |
field: "MetadataMatcher", |
| 494 |
reason: "value is required", |
| 495 |
} |
| 496 |
if !all { |
| 497 |
return err |
| 498 |
} |
| 499 |
errors = append(errors, err) |
| 500 |
} |
| 501 |
|
| 502 |
if all { |
| 503 |
switch v := interface{}(m.GetMetadataMatcher()).(type) { |
| 504 |
case interface{ ValidateAll() error }: |
| 505 |
if err := v.ValidateAll(); err != nil { |
| 506 |
errors = append(errors, SourcedMetadataValidationError{ |
| 507 |
field: "MetadataMatcher", |
| 508 |
reason: "embedded message failed validation", |
| 509 |
cause: err, |
| 510 |
}) |
| 511 |
} |
| 512 |
case interface{ Validate() error }: |
| 513 |
if err := v.Validate(); err != nil { |
| 514 |
errors = append(errors, SourcedMetadataValidationError{ |
| 515 |
field: "MetadataMatcher", |
| 516 |
reason: "embedded message failed validation", |
| 517 |
cause: err, |
| 518 |
}) |
| 519 |
} |
| 520 |
} |
| 521 |
} else if v, ok := interface{}(m.GetMetadataMatcher()).(interface{ Validate() error }); ok { |
| 522 |
if err := v.Validate(); err != nil { |
| 523 |
return SourcedMetadataValidationError{ |
| 524 |
field: "MetadataMatcher", |
| 525 |
reason: "embedded message failed validation", |
| 526 |
cause: err, |
| 527 |
} |
| 528 |
} |
| 529 |
} |
| 530 |
|
| 531 |
if _, ok := MetadataSource_name[int32(m.GetMetadataSource())]; !ok { |
| 532 |
err := SourcedMetadataValidationError{ |
| 533 |
field: "MetadataSource", |
| 534 |
reason: "value must be one of the defined enum values", |
| 535 |
} |
| 536 |
if !all { |
| 537 |
return err |
| 538 |
} |
| 539 |
errors = append(errors, err) |
| 540 |
} |
| 541 |
|
| 542 |
if len(errors) > 0 { |
| 543 |
return SourcedMetadataMultiError(errors) |
| 544 |
} |
| 545 |
|
| 546 |
return nil |
| 547 |
} |
| 548 |
|
| 549 |
// SourcedMetadataMultiError is an error wrapping multiple validation errors |
| 550 |
// returned by SourcedMetadata.ValidateAll() if the designated constraints |
| 551 |
// aren't met. |
| 552 |
type SourcedMetadataMultiError []error |
| 553 |
|
| 554 |
// Error returns a concatenation of all the error messages it wraps. |
| 555 |
func (m SourcedMetadataMultiError) Error() string { |
| 556 |
var msgs []string |
| 557 |
for _, err := range m { |
| 558 |
msgs = append(msgs, err.Error()) |
| 559 |
} |
| 560 |
return strings.Join(msgs, "; ") |
| 561 |
} |
| 562 |
|
| 563 |
// AllErrors returns a list of validation violation errors. |
| 564 |
func (m SourcedMetadataMultiError) AllErrors() []error { return m } |
| 565 |
|
| 566 |
// SourcedMetadataValidationError is the validation error returned by |
| 567 |
// SourcedMetadata.Validate if the designated constraints aren't met. |
| 568 |
type SourcedMetadataValidationError struct { |
| 569 |
field string |
| 570 |
reason string |
| 571 |
cause error |
| 572 |
key bool |
| 573 |
} |
| 574 |
|
| 575 |
// Field function returns field value. |
| 576 |
func (e SourcedMetadataValidationError) Field() string { return e.field } |
| 577 |
|
| 578 |
// Reason function returns reason value. |
| 579 |
func (e SourcedMetadataValidationError) Reason() string { return e.reason } |
| 580 |
|
| 581 |
// Cause function returns cause value. |
| 582 |
func (e SourcedMetadataValidationError) Cause() error { return e.cause } |
| 583 |
|
| 584 |
// Key function returns key value. |
| 585 |
func (e SourcedMetadataValidationError) Key() bool { return e.key } |
| 586 |
|
| 587 |
// ErrorName returns error name. |
| 588 |
func (e SourcedMetadataValidationError) ErrorName() string { return "SourcedMetadataValidationError" } |
| 589 |
|
| 590 |
// Error satisfies the builtin error interface |
| 591 |
func (e SourcedMetadataValidationError) Error() string { |
| 592 |
cause := "" |
| 593 |
if e.cause != nil { |
| 594 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 595 |
} |
| 596 |
|
| 597 |
key := "" |
| 598 |
if e.key { |
| 599 |
key = "key for " |
| 600 |
} |
| 601 |
|
| 602 |
return fmt.Sprintf( |
| 603 |
"invalid %sSourcedMetadata.%s: %s%s", |
| 604 |
key, |
| 605 |
e.field, |
| 606 |
e.reason, |
| 607 |
cause) |
| 608 |
} |
| 609 |
|
| 610 |
var _ error = SourcedMetadataValidationError{} |
| 611 |
|
| 612 |
var _ interface { |
| 613 |
Field() string |
| 614 |
Reason() string |
| 615 |
Key() bool |
| 616 |
Cause() error |
| 617 |
ErrorName() string |
| 618 |
} = SourcedMetadataValidationError{} |
| 619 |
|
| 620 |
// Validate checks the field values on Permission with the rules defined in the |
| 621 |
// proto definition for this message. If any rules are violated, the first |
| 622 |
// error encountered is returned, or nil if there are no violations. |
| 623 |
func (m *Permission) Validate() error { |
| 624 |
return m.validate(false) |
| 625 |
} |
| 626 |
|
| 627 |
// ValidateAll checks the field values on Permission with the rules defined in |
| 628 |
// the proto definition for this message. If any rules are violated, the |
| 629 |
// result is a list of violation errors wrapped in PermissionMultiError, or |
| 630 |
// nil if none found. |
| 631 |
func (m *Permission) ValidateAll() error { |
| 632 |
return m.validate(true) |
| 633 |
} |
| 634 |
|
| 635 |
func (m *Permission) validate(all bool) error { |
| 636 |
if m == nil { |
| 637 |
return nil |
| 638 |
} |
| 639 |
|
| 640 |
var errors []error |
| 641 |
|
| 642 |
oneofRulePresent := false |
| 643 |
switch v := m.Rule.(type) { |
| 644 |
case *Permission_AndRules: |
| 645 |
if v == nil { |
| 646 |
err := PermissionValidationError{ |
| 647 |
field: "Rule", |
| 648 |
reason: "oneof value cannot be a typed-nil", |
| 649 |
} |
| 650 |
if !all { |
| 651 |
return err |
| 652 |
} |
| 653 |
errors = append(errors, err) |
| 654 |
} |
| 655 |
oneofRulePresent = true |
| 656 |
|
| 657 |
if all { |
| 658 |
switch v := interface{}(m.GetAndRules()).(type) { |
| 659 |
case interface{ ValidateAll() error }: |
| 660 |
if err := v.ValidateAll(); err != nil { |
| 661 |
errors = append(errors, PermissionValidationError{ |
| 662 |
field: "AndRules", |
| 663 |
reason: "embedded message failed validation", |
| 664 |
cause: err, |
| 665 |
}) |
| 666 |
} |
| 667 |
case interface{ Validate() error }: |
| 668 |
if err := v.Validate(); err != nil { |
| 669 |
errors = append(errors, PermissionValidationError{ |
| 670 |
field: "AndRules", |
| 671 |
reason: "embedded message failed validation", |
| 672 |
cause: err, |
| 673 |
}) |
| 674 |
} |
| 675 |
} |
| 676 |
} else if v, ok := interface{}(m.GetAndRules()).(interface{ Validate() error }); ok { |
| 677 |
if err := v.Validate(); err != nil { |
| 678 |
return PermissionValidationError{ |
| 679 |
field: "AndRules", |
| 680 |
reason: "embedded message failed validation", |
| 681 |
cause: err, |
| 682 |
} |
| 683 |
} |
| 684 |
} |
| 685 |
|
| 686 |
case *Permission_OrRules: |
| 687 |
if v == nil { |
| 688 |
err := PermissionValidationError{ |
| 689 |
field: "Rule", |
| 690 |
reason: "oneof value cannot be a typed-nil", |
| 691 |
} |
| 692 |
if !all { |
| 693 |
return err |
| 694 |
} |
| 695 |
errors = append(errors, err) |
| 696 |
} |
| 697 |
oneofRulePresent = true |
| 698 |
|
| 699 |
if all { |
| 700 |
switch v := interface{}(m.GetOrRules()).(type) { |
| 701 |
case interface{ ValidateAll() error }: |
| 702 |
if err := v.ValidateAll(); err != nil { |
| 703 |
errors = append(errors, PermissionValidationError{ |
| 704 |
field: "OrRules", |
| 705 |
reason: "embedded message failed validation", |
| 706 |
cause: err, |
| 707 |
}) |
| 708 |
} |
| 709 |
case interface{ Validate() error }: |
| 710 |
if err := v.Validate(); err != nil { |
| 711 |
errors = append(errors, PermissionValidationError{ |
| 712 |
field: "OrRules", |
| 713 |
reason: "embedded message failed validation", |
| 714 |
cause: err, |
| 715 |
}) |
| 716 |
} |
| 717 |
} |
| 718 |
} else if v, ok := interface{}(m.GetOrRules()).(interface{ Validate() error }); ok { |
| 719 |
if err := v.Validate(); err != nil { |
| 720 |
return PermissionValidationError{ |
| 721 |
field: "OrRules", |
| 722 |
reason: "embedded message failed validation", |
| 723 |
cause: err, |
| 724 |
} |
| 725 |
} |
| 726 |
} |
| 727 |
|
| 728 |
case *Permission_Any: |
| 729 |
if v == nil { |
| 730 |
err := PermissionValidationError{ |
| 731 |
field: "Rule", |
| 732 |
reason: "oneof value cannot be a typed-nil", |
| 733 |
} |
| 734 |
if !all { |
| 735 |
return err |
| 736 |
} |
| 737 |
errors = append(errors, err) |
| 738 |
} |
| 739 |
oneofRulePresent = true |
| 740 |
|
| 741 |
if m.GetAny() != true { |
| 742 |
err := PermissionValidationError{ |
| 743 |
field: "Any", |
| 744 |
reason: "value must equal true", |
| 745 |
} |
| 746 |
if !all { |
| 747 |
return err |
| 748 |
} |
| 749 |
errors = append(errors, err) |
| 750 |
} |
| 751 |
|
| 752 |
case *Permission_Header: |
| 753 |
if v == nil { |
| 754 |
err := PermissionValidationError{ |
| 755 |
field: "Rule", |
| 756 |
reason: "oneof value cannot be a typed-nil", |
| 757 |
} |
| 758 |
if !all { |
| 759 |
return err |
| 760 |
} |
| 761 |
errors = append(errors, err) |
| 762 |
} |
| 763 |
oneofRulePresent = true |
| 764 |
|
| 765 |
if all { |
| 766 |
switch v := interface{}(m.GetHeader()).(type) { |
| 767 |
case interface{ ValidateAll() error }: |
| 768 |
if err := v.ValidateAll(); err != nil { |
| 769 |
errors = append(errors, PermissionValidationError{ |
| 770 |
field: "Header", |
| 771 |
reason: "embedded message failed validation", |
| 772 |
cause: err, |
| 773 |
}) |
| 774 |
} |
| 775 |
case interface{ Validate() error }: |
| 776 |
if err := v.Validate(); err != nil { |
| 777 |
errors = append(errors, PermissionValidationError{ |
| 778 |
field: "Header", |
| 779 |
reason: "embedded message failed validation", |
| 780 |
cause: err, |
| 781 |
}) |
| 782 |
} |
| 783 |
} |
| 784 |
} else if v, ok := interface{}(m.GetHeader()).(interface{ Validate() error }); ok { |
| 785 |
if err := v.Validate(); err != nil { |
| 786 |
return PermissionValidationError{ |
| 787 |
field: "Header", |
| 788 |
reason: "embedded message failed validation", |
| 789 |
cause: err, |
| 790 |
} |
| 791 |
} |
| 792 |
} |
| 793 |
|
| 794 |
case *Permission_UrlPath: |
| 795 |
if v == nil { |
| 796 |
err := PermissionValidationError{ |
| 797 |
field: "Rule", |
| 798 |
reason: "oneof value cannot be a typed-nil", |
| 799 |
} |
| 800 |
if !all { |
| 801 |
return err |
| 802 |
} |
| 803 |
errors = append(errors, err) |
| 804 |
} |
| 805 |
oneofRulePresent = true |
| 806 |
|
| 807 |
if all { |
| 808 |
switch v := interface{}(m.GetUrlPath()).(type) { |
| 809 |
case interface{ ValidateAll() error }: |
| 810 |
if err := v.ValidateAll(); err != nil { |
| 811 |
errors = append(errors, PermissionValidationError{ |
| 812 |
field: "UrlPath", |
| 813 |
reason: "embedded message failed validation", |
| 814 |
cause: err, |
| 815 |
}) |
| 816 |
} |
| 817 |
case interface{ Validate() error }: |
| 818 |
if err := v.Validate(); err != nil { |
| 819 |
errors = append(errors, PermissionValidationError{ |
| 820 |
field: "UrlPath", |
| 821 |
reason: "embedded message failed validation", |
| 822 |
cause: err, |
| 823 |
}) |
| 824 |
} |
| 825 |
} |
| 826 |
} else if v, ok := interface{}(m.GetUrlPath()).(interface{ Validate() error }); ok { |
| 827 |
if err := v.Validate(); err != nil { |
| 828 |
return PermissionValidationError{ |
| 829 |
field: "UrlPath", |
| 830 |
reason: "embedded message failed validation", |
| 831 |
cause: err, |
| 832 |
} |
| 833 |
} |
| 834 |
} |
| 835 |
|
| 836 |
case *Permission_DestinationIp: |
| 837 |
if v == nil { |
| 838 |
err := PermissionValidationError{ |
| 839 |
field: "Rule", |
| 840 |
reason: "oneof value cannot be a typed-nil", |
| 841 |
} |
| 842 |
if !all { |
| 843 |
return err |
| 844 |
} |
| 845 |
errors = append(errors, err) |
| 846 |
} |
| 847 |
oneofRulePresent = true |
| 848 |
|
| 849 |
if all { |
| 850 |
switch v := interface{}(m.GetDestinationIp()).(type) { |
| 851 |
case interface{ ValidateAll() error }: |
| 852 |
if err := v.ValidateAll(); err != nil { |
| 853 |
errors = append(errors, PermissionValidationError{ |
| 854 |
field: "DestinationIp", |
| 855 |
reason: "embedded message failed validation", |
| 856 |
cause: err, |
| 857 |
}) |
| 858 |
} |
| 859 |
case interface{ Validate() error }: |
| 860 |
if err := v.Validate(); err != nil { |
| 861 |
errors = append(errors, PermissionValidationError{ |
| 862 |
field: "DestinationIp", |
| 863 |
reason: "embedded message failed validation", |
| 864 |
cause: err, |
| 865 |
}) |
| 866 |
} |
| 867 |
} |
| 868 |
} else if v, ok := interface{}(m.GetDestinationIp()).(interface{ Validate() error }); ok { |
| 869 |
if err := v.Validate(); err != nil { |
| 870 |
return PermissionValidationError{ |
| 871 |
field: "DestinationIp", |
| 872 |
reason: "embedded message failed validation", |
| 873 |
cause: err, |
| 874 |
} |
| 875 |
} |
| 876 |
} |
| 877 |
|
| 878 |
case *Permission_DestinationPort: |
| 879 |
if v == nil { |
| 880 |
err := PermissionValidationError{ |
| 881 |
field: "Rule", |
| 882 |
reason: "oneof value cannot be a typed-nil", |
| 883 |
} |
| 884 |
if !all { |
| 885 |
return err |
| 886 |
} |
| 887 |
errors = append(errors, err) |
| 888 |
} |
| 889 |
oneofRulePresent = true |
| 890 |
|
| 891 |
if m.GetDestinationPort() > 65535 { |
| 892 |
err := PermissionValidationError{ |
| 893 |
field: "DestinationPort", |
| 894 |
reason: "value must be less than or equal to 65535", |
| 895 |
} |
| 896 |
if !all { |
| 897 |
return err |
| 898 |
} |
| 899 |
errors = append(errors, err) |
| 900 |
} |
| 901 |
|
| 902 |
case *Permission_DestinationPortRange: |
| 903 |
if v == nil { |
| 904 |
err := PermissionValidationError{ |
| 905 |
field: "Rule", |
| 906 |
reason: "oneof value cannot be a typed-nil", |
| 907 |
} |
| 908 |
if !all { |
| 909 |
return err |
| 910 |
} |
| 911 |
errors = append(errors, err) |
| 912 |
} |
| 913 |
oneofRulePresent = true |
| 914 |
|
| 915 |
if all { |
| 916 |
switch v := interface{}(m.GetDestinationPortRange()).(type) { |
| 917 |
case interface{ ValidateAll() error }: |
| 918 |
if err := v.ValidateAll(); err != nil { |
| 919 |
errors = append(errors, PermissionValidationError{ |
| 920 |
field: "DestinationPortRange", |
| 921 |
reason: "embedded message failed validation", |
| 922 |
cause: err, |
| 923 |
}) |
| 924 |
} |
| 925 |
case interface{ Validate() error }: |
| 926 |
if err := v.Validate(); err != nil { |
| 927 |
errors = append(errors, PermissionValidationError{ |
| 928 |
field: "DestinationPortRange", |
| 929 |
reason: "embedded message failed validation", |
| 930 |
cause: err, |
| 931 |
}) |
| 932 |
} |
| 933 |
} |
| 934 |
} else if v, ok := interface{}(m.GetDestinationPortRange()).(interface{ Validate() error }); ok { |
| 935 |
if err := v.Validate(); err != nil { |
| 936 |
return PermissionValidationError{ |
| 937 |
field: "DestinationPortRange", |
| 938 |
reason: "embedded message failed validation", |
| 939 |
cause: err, |
| 940 |
} |
| 941 |
} |
| 942 |
} |
| 943 |
|
| 944 |
case *Permission_Metadata: |
| 945 |
if v == nil { |
| 946 |
err := PermissionValidationError{ |
| 947 |
field: "Rule", |
| 948 |
reason: "oneof value cannot be a typed-nil", |
| 949 |
} |
| 950 |
if !all { |
| 951 |
return err |
| 952 |
} |
| 953 |
errors = append(errors, err) |
| 954 |
} |
| 955 |
oneofRulePresent = true |
| 956 |
|
| 957 |
if all { |
| 958 |
switch v := interface{}(m.GetMetadata()).(type) { |
| 959 |
case interface{ ValidateAll() error }: |
| 960 |
if err := v.ValidateAll(); err != nil { |
| 961 |
errors = append(errors, PermissionValidationError{ |
| 962 |
field: "Metadata", |
| 963 |
reason: "embedded message failed validation", |
| 964 |
cause: err, |
| 965 |
}) |
| 966 |
} |
| 967 |
case interface{ Validate() error }: |
| 968 |
if err := v.Validate(); err != nil { |
| 969 |
errors = append(errors, PermissionValidationError{ |
| 970 |
field: "Metadata", |
| 971 |
reason: "embedded message failed validation", |
| 972 |
cause: err, |
| 973 |
}) |
| 974 |
} |
| 975 |
} |
| 976 |
} else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { |
| 977 |
if err := v.Validate(); err != nil { |
| 978 |
return PermissionValidationError{ |
| 979 |
field: "Metadata", |
| 980 |
reason: "embedded message failed validation", |
| 981 |
cause: err, |
| 982 |
} |
| 983 |
} |
| 984 |
} |
| 985 |
|
| 986 |
case *Permission_NotRule: |
| 987 |
if v == nil { |
| 988 |
err := PermissionValidationError{ |
| 989 |
field: "Rule", |
| 990 |
reason: "oneof value cannot be a typed-nil", |
| 991 |
} |
| 992 |
if !all { |
| 993 |
return err |
| 994 |
} |
| 995 |
errors = append(errors, err) |
| 996 |
} |
| 997 |
oneofRulePresent = true |
| 998 |
|
| 999 |
if all { |
| 1000 |
switch v := interface{}(m.GetNotRule()).(type) { |
| 1001 |
case interface{ ValidateAll() error }: |
| 1002 |
if err := v.ValidateAll(); err != nil { |
| 1003 |
errors = append(errors, PermissionValidationError{ |
| 1004 |
field: "NotRule", |
| 1005 |
reason: "embedded message failed validation", |
| 1006 |
cause: err, |
| 1007 |
}) |
| 1008 |
} |
| 1009 |
case interface{ Validate() error }: |
| 1010 |
if err := v.Validate(); err != nil { |
| 1011 |
errors = append(errors, PermissionValidationError{ |
| 1012 |
field: "NotRule", |
| 1013 |
reason: "embedded message failed validation", |
| 1014 |
cause: err, |
| 1015 |
}) |
| 1016 |
} |
| 1017 |
} |
| 1018 |
} else if v, ok := interface{}(m.GetNotRule()).(interface{ Validate() error }); ok { |
| 1019 |
if err := v.Validate(); err != nil { |
| 1020 |
return PermissionValidationError{ |
| 1021 |
field: "NotRule", |
| 1022 |
reason: "embedded message failed validation", |
| 1023 |
cause: err, |
| 1024 |
} |
| 1025 |
} |
| 1026 |
} |
| 1027 |
|
| 1028 |
case *Permission_RequestedServerName: |
| 1029 |
if v == nil { |
| 1030 |
err := PermissionValidationError{ |
| 1031 |
field: "Rule", |
| 1032 |
reason: "oneof value cannot be a typed-nil", |
| 1033 |
} |
| 1034 |
if !all { |
| 1035 |
return err |
| 1036 |
} |
| 1037 |
errors = append(errors, err) |
| 1038 |
} |
| 1039 |
oneofRulePresent = true |
| 1040 |
|
| 1041 |
if all { |
| 1042 |
switch v := interface{}(m.GetRequestedServerName()).(type) { |
| 1043 |
case interface{ ValidateAll() error }: |
| 1044 |
if err := v.ValidateAll(); err != nil { |
| 1045 |
errors = append(errors, PermissionValidationError{ |
| 1046 |
field: "RequestedServerName", |
| 1047 |
reason: "embedded message failed validation", |
| 1048 |
cause: err, |
| 1049 |
}) |
| 1050 |
} |
| 1051 |
case interface{ Validate() error }: |
| 1052 |
if err := v.Validate(); err != nil { |
| 1053 |
errors = append(errors, PermissionValidationError{ |
| 1054 |
field: "RequestedServerName", |
| 1055 |
reason: "embedded message failed validation", |
| 1056 |
cause: err, |
| 1057 |
}) |
| 1058 |
} |
| 1059 |
} |
| 1060 |
} else if v, ok := interface{}(m.GetRequestedServerName()).(interface{ Validate() error }); ok { |
| 1061 |
if err := v.Validate(); err != nil { |
| 1062 |
return PermissionValidationError{ |
| 1063 |
field: "RequestedServerName", |
| 1064 |
reason: "embedded message failed validation", |
| 1065 |
cause: err, |
| 1066 |
} |
| 1067 |
} |
| 1068 |
} |
| 1069 |
|
| 1070 |
case *Permission_Matcher: |
| 1071 |
if v == nil { |
| 1072 |
err := PermissionValidationError{ |
| 1073 |
field: "Rule", |
| 1074 |
reason: "oneof value cannot be a typed-nil", |
| 1075 |
} |
| 1076 |
if !all { |
| 1077 |
return err |
| 1078 |
} |
| 1079 |
errors = append(errors, err) |
| 1080 |
} |
| 1081 |
oneofRulePresent = true |
| 1082 |
|
| 1083 |
if all { |
| 1084 |
switch v := interface{}(m.GetMatcher()).(type) { |
| 1085 |
case interface{ ValidateAll() error }: |
| 1086 |
if err := v.ValidateAll(); err != nil { |
| 1087 |
errors = append(errors, PermissionValidationError{ |
| 1088 |
field: "Matcher", |
| 1089 |
reason: "embedded message failed validation", |
| 1090 |
cause: err, |
| 1091 |
}) |
| 1092 |
} |
| 1093 |
case interface{ Validate() error }: |
| 1094 |
if err := v.Validate(); err != nil { |
| 1095 |
errors = append(errors, PermissionValidationError{ |
| 1096 |
field: "Matcher", |
| 1097 |
reason: "embedded message failed validation", |
| 1098 |
cause: err, |
| 1099 |
}) |
| 1100 |
} |
| 1101 |
} |
| 1102 |
} else if v, ok := interface{}(m.GetMatcher()).(interface{ Validate() error }); ok { |
| 1103 |
if err := v.Validate(); err != nil { |
| 1104 |
return PermissionValidationError{ |
| 1105 |
field: "Matcher", |
| 1106 |
reason: "embedded message failed validation", |
| 1107 |
cause: err, |
| 1108 |
} |
| 1109 |
} |
| 1110 |
} |
| 1111 |
|
| 1112 |
case *Permission_UriTemplate: |
| 1113 |
if v == nil { |
| 1114 |
err := PermissionValidationError{ |
| 1115 |
field: "Rule", |
| 1116 |
reason: "oneof value cannot be a typed-nil", |
| 1117 |
} |
| 1118 |
if !all { |
| 1119 |
return err |
| 1120 |
} |
| 1121 |
errors = append(errors, err) |
| 1122 |
} |
| 1123 |
oneofRulePresent = true |
| 1124 |
|
| 1125 |
if all { |
| 1126 |
switch v := interface{}(m.GetUriTemplate()).(type) { |
| 1127 |
case interface{ ValidateAll() error }: |
| 1128 |
if err := v.ValidateAll(); err != nil { |
| 1129 |
errors = append(errors, PermissionValidationError{ |
| 1130 |
field: "UriTemplate", |
| 1131 |
reason: "embedded message failed validation", |
| 1132 |
cause: err, |
| 1133 |
}) |
| 1134 |
} |
| 1135 |
case interface{ Validate() error }: |
| 1136 |
if err := v.Validate(); err != nil { |
| 1137 |
errors = append(errors, PermissionValidationError{ |
| 1138 |
field: "UriTemplate", |
| 1139 |
reason: "embedded message failed validation", |
| 1140 |
cause: err, |
| 1141 |
}) |
| 1142 |
} |
| 1143 |
} |
| 1144 |
} else if v, ok := interface{}(m.GetUriTemplate()).(interface{ Validate() error }); ok { |
| 1145 |
if err := v.Validate(); err != nil { |
| 1146 |
return PermissionValidationError{ |
| 1147 |
field: "UriTemplate", |
| 1148 |
reason: "embedded message failed validation", |
| 1149 |
cause: err, |
| 1150 |
} |
| 1151 |
} |
| 1152 |
} |
| 1153 |
|
| 1154 |
case *Permission_SourcedMetadata: |
| 1155 |
if v == nil { |
| 1156 |
err := PermissionValidationError{ |
| 1157 |
field: "Rule", |
| 1158 |
reason: "oneof value cannot be a typed-nil", |
| 1159 |
} |
| 1160 |
if !all { |
| 1161 |
return err |
| 1162 |
} |
| 1163 |
errors = append(errors, err) |
| 1164 |
} |
| 1165 |
oneofRulePresent = true |
| 1166 |
|
| 1167 |
if all { |
| 1168 |
switch v := interface{}(m.GetSourcedMetadata()).(type) { |
| 1169 |
case interface{ ValidateAll() error }: |
| 1170 |
if err := v.ValidateAll(); err != nil { |
| 1171 |
errors = append(errors, PermissionValidationError{ |
| 1172 |
field: "SourcedMetadata", |
| 1173 |
reason: "embedded message failed validation", |
| 1174 |
cause: err, |
| 1175 |
}) |
| 1176 |
} |
| 1177 |
case interface{ Validate() error }: |
| 1178 |
if err := v.Validate(); err != nil { |
| 1179 |
errors = append(errors, PermissionValidationError{ |
| 1180 |
field: "SourcedMetadata", |
| 1181 |
reason: "embedded message failed validation", |
| 1182 |
cause: err, |
| 1183 |
}) |
| 1184 |
} |
| 1185 |
} |
| 1186 |
} else if v, ok := interface{}(m.GetSourcedMetadata()).(interface{ Validate() error }); ok { |
| 1187 |
if err := v.Validate(); err != nil { |
| 1188 |
return PermissionValidationError{ |
| 1189 |
field: "SourcedMetadata", |
| 1190 |
reason: "embedded message failed validation", |
| 1191 |
cause: err, |
| 1192 |
} |
| 1193 |
} |
| 1194 |
} |
| 1195 |
|
| 1196 |
default: |
| 1197 |
_ = v // ensures v is used |
| 1198 |
} |
| 1199 |
if !oneofRulePresent { |
| 1200 |
err := PermissionValidationError{ |
| 1201 |
field: "Rule", |
| 1202 |
reason: "value is required", |
| 1203 |
} |
| 1204 |
if !all { |
| 1205 |
return err |
| 1206 |
} |
| 1207 |
errors = append(errors, err) |
| 1208 |
} |
| 1209 |
|
| 1210 |
if len(errors) > 0 { |
| 1211 |
return PermissionMultiError(errors) |
| 1212 |
} |
| 1213 |
|
| 1214 |
return nil |
| 1215 |
} |
| 1216 |
|
| 1217 |
// PermissionMultiError is an error wrapping multiple validation errors |
| 1218 |
// returned by Permission.ValidateAll() if the designated constraints aren't met. |
| 1219 |
type PermissionMultiError []error |
| 1220 |
|
| 1221 |
// Error returns a concatenation of all the error messages it wraps. |
| 1222 |
func (m PermissionMultiError) Error() string { |
| 1223 |
var msgs []string |
| 1224 |
for _, err := range m { |
| 1225 |
msgs = append(msgs, err.Error()) |
| 1226 |
} |
| 1227 |
return strings.Join(msgs, "; ") |
| 1228 |
} |
| 1229 |
|
| 1230 |
// AllErrors returns a list of validation violation errors. |
| 1231 |
func (m PermissionMultiError) AllErrors() []error { return m } |
| 1232 |
|
| 1233 |
// PermissionValidationError is the validation error returned by |
| 1234 |
// Permission.Validate if the designated constraints aren't met. |
| 1235 |
type PermissionValidationError struct { |
| 1236 |
field string |
| 1237 |
reason string |
| 1238 |
cause error |
| 1239 |
key bool |
| 1240 |
} |
| 1241 |
|
| 1242 |
// Field function returns field value. |
| 1243 |
func (e PermissionValidationError) Field() string { return e.field } |
| 1244 |
|
| 1245 |
// Reason function returns reason value. |
| 1246 |
func (e PermissionValidationError) Reason() string { return e.reason } |
| 1247 |
|
| 1248 |
// Cause function returns cause value. |
| 1249 |
func (e PermissionValidationError) Cause() error { return e.cause } |
| 1250 |
|
| 1251 |
// Key function returns key value. |
| 1252 |
func (e PermissionValidationError) Key() bool { return e.key } |
| 1253 |
|
| 1254 |
// ErrorName returns error name. |
| 1255 |
func (e PermissionValidationError) ErrorName() string { return "PermissionValidationError" } |
| 1256 |
|
| 1257 |
// Error satisfies the builtin error interface |
| 1258 |
func (e PermissionValidationError) Error() string { |
| 1259 |
cause := "" |
| 1260 |
if e.cause != nil { |
| 1261 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 1262 |
} |
| 1263 |
|
| 1264 |
key := "" |
| 1265 |
if e.key { |
| 1266 |
key = "key for " |
| 1267 |
} |
| 1268 |
|
| 1269 |
return fmt.Sprintf( |
| 1270 |
"invalid %sPermission.%s: %s%s", |
| 1271 |
key, |
| 1272 |
e.field, |
| 1273 |
e.reason, |
| 1274 |
cause) |
| 1275 |
} |
| 1276 |
|
| 1277 |
var _ error = PermissionValidationError{} |
| 1278 |
|
| 1279 |
var _ interface { |
| 1280 |
Field() string |
| 1281 |
Reason() string |
| 1282 |
Key() bool |
| 1283 |
Cause() error |
| 1284 |
ErrorName() string |
| 1285 |
} = PermissionValidationError{} |
| 1286 |
|
| 1287 |
// Validate checks the field values on Principal with the rules defined in the |
| 1288 |
// proto definition for this message. If any rules are violated, the first |
| 1289 |
// error encountered is returned, or nil if there are no violations. |
| 1290 |
func (m *Principal) Validate() error { |
| 1291 |
return m.validate(false) |
| 1292 |
} |
| 1293 |
|
| 1294 |
// ValidateAll checks the field values on Principal with the rules defined in |
| 1295 |
// the proto definition for this message. If any rules are violated, the |
| 1296 |
// result is a list of violation errors wrapped in PrincipalMultiError, or nil |
| 1297 |
// if none found. |
| 1298 |
func (m *Principal) ValidateAll() error { |
| 1299 |
return m.validate(true) |
| 1300 |
} |
| 1301 |
|
| 1302 |
func (m *Principal) validate(all bool) error { |
| 1303 |
if m == nil { |
| 1304 |
return nil |
| 1305 |
} |
| 1306 |
|
| 1307 |
var errors []error |
| 1308 |
|
| 1309 |
oneofIdentifierPresent := false |
| 1310 |
switch v := m.Identifier.(type) { |
| 1311 |
case *Principal_AndIds: |
| 1312 |
if v == nil { |
| 1313 |
err := PrincipalValidationError{ |
| 1314 |
field: "Identifier", |
| 1315 |
reason: "oneof value cannot be a typed-nil", |
| 1316 |
} |
| 1317 |
if !all { |
| 1318 |
return err |
| 1319 |
} |
| 1320 |
errors = append(errors, err) |
| 1321 |
} |
| 1322 |
oneofIdentifierPresent = true |
| 1323 |
|
| 1324 |
if all { |
| 1325 |
switch v := interface{}(m.GetAndIds()).(type) { |
| 1326 |
case interface{ ValidateAll() error }: |
| 1327 |
if err := v.ValidateAll(); err != nil { |
| 1328 |
errors = append(errors, PrincipalValidationError{ |
| 1329 |
field: "AndIds", |
| 1330 |
reason: "embedded message failed validation", |
| 1331 |
cause: err, |
| 1332 |
}) |
| 1333 |
} |
| 1334 |
case interface{ Validate() error }: |
| 1335 |
if err := v.Validate(); err != nil { |
| 1336 |
errors = append(errors, PrincipalValidationError{ |
| 1337 |
field: "AndIds", |
| 1338 |
reason: "embedded message failed validation", |
| 1339 |
cause: err, |
| 1340 |
}) |
| 1341 |
} |
| 1342 |
} |
| 1343 |
} else if v, ok := interface{}(m.GetAndIds()).(interface{ Validate() error }); ok { |
| 1344 |
if err := v.Validate(); err != nil { |
| 1345 |
return PrincipalValidationError{ |
| 1346 |
field: "AndIds", |
| 1347 |
reason: "embedded message failed validation", |
| 1348 |
cause: err, |
| 1349 |
} |
| 1350 |
} |
| 1351 |
} |
| 1352 |
|
| 1353 |
case *Principal_OrIds: |
| 1354 |
if v == nil { |
| 1355 |
err := PrincipalValidationError{ |
| 1356 |
field: "Identifier", |
| 1357 |
reason: "oneof value cannot be a typed-nil", |
| 1358 |
} |
| 1359 |
if !all { |
| 1360 |
return err |
| 1361 |
} |
| 1362 |
errors = append(errors, err) |
| 1363 |
} |
| 1364 |
oneofIdentifierPresent = true |
| 1365 |
|
| 1366 |
if all { |
| 1367 |
switch v := interface{}(m.GetOrIds()).(type) { |
| 1368 |
case interface{ ValidateAll() error }: |
| 1369 |
if err := v.ValidateAll(); err != nil { |
| 1370 |
errors = append(errors, PrincipalValidationError{ |
| 1371 |
field: "OrIds", |
| 1372 |
reason: "embedded message failed validation", |
| 1373 |
cause: err, |
| 1374 |
}) |
| 1375 |
} |
| 1376 |
case interface{ Validate() error }: |
| 1377 |
if err := v.Validate(); err != nil { |
| 1378 |
errors = append(errors, PrincipalValidationError{ |
| 1379 |
field: "OrIds", |
| 1380 |
reason: "embedded message failed validation", |
| 1381 |
cause: err, |
| 1382 |
}) |
| 1383 |
} |
| 1384 |
} |
| 1385 |
} else if v, ok := interface{}(m.GetOrIds()).(interface{ Validate() error }); ok { |
| 1386 |
if err := v.Validate(); err != nil { |
| 1387 |
return PrincipalValidationError{ |
| 1388 |
field: "OrIds", |
| 1389 |
reason: "embedded message failed validation", |
| 1390 |
cause: err, |
| 1391 |
} |
| 1392 |
} |
| 1393 |
} |
| 1394 |
|
| 1395 |
case *Principal_Any: |
| 1396 |
if v == nil { |
| 1397 |
err := PrincipalValidationError{ |
| 1398 |
field: "Identifier", |
| 1399 |
reason: "oneof value cannot be a typed-nil", |
| 1400 |
} |
| 1401 |
if !all { |
| 1402 |
return err |
| 1403 |
} |
| 1404 |
errors = append(errors, err) |
| 1405 |
} |
| 1406 |
oneofIdentifierPresent = true |
| 1407 |
|
| 1408 |
if m.GetAny() != true { |
| 1409 |
err := PrincipalValidationError{ |
| 1410 |
field: "Any", |
| 1411 |
reason: "value must equal true", |
| 1412 |
} |
| 1413 |
if !all { |
| 1414 |
return err |
| 1415 |
} |
| 1416 |
errors = append(errors, err) |
| 1417 |
} |
| 1418 |
|
| 1419 |
case *Principal_Authenticated_: |
| 1420 |
if v == nil { |
| 1421 |
err := PrincipalValidationError{ |
| 1422 |
field: "Identifier", |
| 1423 |
reason: "oneof value cannot be a typed-nil", |
| 1424 |
} |
| 1425 |
if !all { |
| 1426 |
return err |
| 1427 |
} |
| 1428 |
errors = append(errors, err) |
| 1429 |
} |
| 1430 |
oneofIdentifierPresent = true |
| 1431 |
|
| 1432 |
if all { |
| 1433 |
switch v := interface{}(m.GetAuthenticated()).(type) { |
| 1434 |
case interface{ ValidateAll() error }: |
| 1435 |
if err := v.ValidateAll(); err != nil { |
| 1436 |
errors = append(errors, PrincipalValidationError{ |
| 1437 |
field: "Authenticated", |
| 1438 |
reason: "embedded message failed validation", |
| 1439 |
cause: err, |
| 1440 |
}) |
| 1441 |
} |
| 1442 |
case interface{ Validate() error }: |
| 1443 |
if err := v.Validate(); err != nil { |
| 1444 |
errors = append(errors, PrincipalValidationError{ |
| 1445 |
field: "Authenticated", |
| 1446 |
reason: "embedded message failed validation", |
| 1447 |
cause: err, |
| 1448 |
}) |
| 1449 |
} |
| 1450 |
} |
| 1451 |
} else if v, ok := interface{}(m.GetAuthenticated()).(interface{ Validate() error }); ok { |
| 1452 |
if err := v.Validate(); err != nil { |
| 1453 |
return PrincipalValidationError{ |
| 1454 |
field: "Authenticated", |
| 1455 |
reason: "embedded message failed validation", |
| 1456 |
cause: err, |
| 1457 |
} |
| 1458 |
} |
| 1459 |
} |
| 1460 |
|
| 1461 |
case *Principal_SourceIp: |
| 1462 |
if v == nil { |
| 1463 |
err := PrincipalValidationError{ |
| 1464 |
field: "Identifier", |
| 1465 |
reason: "oneof value cannot be a typed-nil", |
| 1466 |
} |
| 1467 |
if !all { |
| 1468 |
return err |
| 1469 |
} |
| 1470 |
errors = append(errors, err) |
| 1471 |
} |
| 1472 |
oneofIdentifierPresent = true |
| 1473 |
|
| 1474 |
if all { |
| 1475 |
switch v := interface{}(m.GetSourceIp()).(type) { |
| 1476 |
case interface{ ValidateAll() error }: |
| 1477 |
if err := v.ValidateAll(); err != nil { |
| 1478 |
errors = append(errors, PrincipalValidationError{ |
| 1479 |
field: "SourceIp", |
| 1480 |
reason: "embedded message failed validation", |
| 1481 |
cause: err, |
| 1482 |
}) |
| 1483 |
} |
| 1484 |
case interface{ Validate() error }: |
| 1485 |
if err := v.Validate(); err != nil { |
| 1486 |
errors = append(errors, PrincipalValidationError{ |
| 1487 |
field: "SourceIp", |
| 1488 |
reason: "embedded message failed validation", |
| 1489 |
cause: err, |
| 1490 |
}) |
| 1491 |
} |
| 1492 |
} |
| 1493 |
} else if v, ok := interface{}(m.GetSourceIp()).(interface{ Validate() error }); ok { |
| 1494 |
if err := v.Validate(); err != nil { |
| 1495 |
return PrincipalValidationError{ |
| 1496 |
field: "SourceIp", |
| 1497 |
reason: "embedded message failed validation", |
| 1498 |
cause: err, |
| 1499 |
} |
| 1500 |
} |
| 1501 |
} |
| 1502 |
|
| 1503 |
case *Principal_DirectRemoteIp: |
| 1504 |
if v == nil { |
| 1505 |
err := PrincipalValidationError{ |
| 1506 |
field: "Identifier", |
| 1507 |
reason: "oneof value cannot be a typed-nil", |
| 1508 |
} |
| 1509 |
if !all { |
| 1510 |
return err |
| 1511 |
} |
| 1512 |
errors = append(errors, err) |
| 1513 |
} |
| 1514 |
oneofIdentifierPresent = true |
| 1515 |
|
| 1516 |
if all { |
| 1517 |
switch v := interface{}(m.GetDirectRemoteIp()).(type) { |
| 1518 |
case interface{ ValidateAll() error }: |
| 1519 |
if err := v.ValidateAll(); err != nil { |
| 1520 |
errors = append(errors, PrincipalValidationError{ |
| 1521 |
field: "DirectRemoteIp", |
| 1522 |
reason: "embedded message failed validation", |
| 1523 |
cause: err, |
| 1524 |
}) |
| 1525 |
} |
| 1526 |
case interface{ Validate() error }: |
| 1527 |
if err := v.Validate(); err != nil { |
| 1528 |
errors = append(errors, PrincipalValidationError{ |
| 1529 |
field: "DirectRemoteIp", |
| 1530 |
reason: "embedded message failed validation", |
| 1531 |
cause: err, |
| 1532 |
}) |
| 1533 |
} |
| 1534 |
} |
| 1535 |
} else if v, ok := interface{}(m.GetDirectRemoteIp()).(interface{ Validate() error }); ok { |
| 1536 |
if err := v.Validate(); err != nil { |
| 1537 |
return PrincipalValidationError{ |
| 1538 |
field: "DirectRemoteIp", |
| 1539 |
reason: "embedded message failed validation", |
| 1540 |
cause: err, |
| 1541 |
} |
| 1542 |
} |
| 1543 |
} |
| 1544 |
|
| 1545 |
case *Principal_RemoteIp: |
| 1546 |
if v == nil { |
| 1547 |
err := PrincipalValidationError{ |
| 1548 |
field: "Identifier", |
| 1549 |
reason: "oneof value cannot be a typed-nil", |
| 1550 |
} |
| 1551 |
if !all { |
| 1552 |
return err |
| 1553 |
} |
| 1554 |
errors = append(errors, err) |
| 1555 |
} |
| 1556 |
oneofIdentifierPresent = true |
| 1557 |
|
| 1558 |
if all { |
| 1559 |
switch v := interface{}(m.GetRemoteIp()).(type) { |
| 1560 |
case interface{ ValidateAll() error }: |
| 1561 |
if err := v.ValidateAll(); err != nil { |
| 1562 |
errors = append(errors, PrincipalValidationError{ |
| 1563 |
field: "RemoteIp", |
| 1564 |
reason: "embedded message failed validation", |
| 1565 |
cause: err, |
| 1566 |
}) |
| 1567 |
} |
| 1568 |
case interface{ Validate() error }: |
| 1569 |
if err := v.Validate(); err != nil { |
| 1570 |
errors = append(errors, PrincipalValidationError{ |
| 1571 |
field: "RemoteIp", |
| 1572 |
reason: "embedded message failed validation", |
| 1573 |
cause: err, |
| 1574 |
}) |
| 1575 |
} |
| 1576 |
} |
| 1577 |
} else if v, ok := interface{}(m.GetRemoteIp()).(interface{ Validate() error }); ok { |
| 1578 |
if err := v.Validate(); err != nil { |
| 1579 |
return PrincipalValidationError{ |
| 1580 |
field: "RemoteIp", |
| 1581 |
reason: "embedded message failed validation", |
| 1582 |
cause: err, |
| 1583 |
} |
| 1584 |
} |
| 1585 |
} |
| 1586 |
|
| 1587 |
case *Principal_Header: |
| 1588 |
if v == nil { |
| 1589 |
err := PrincipalValidationError{ |
| 1590 |
field: "Identifier", |
| 1591 |
reason: "oneof value cannot be a typed-nil", |
| 1592 |
} |
| 1593 |
if !all { |
| 1594 |
return err |
| 1595 |
} |
| 1596 |
errors = append(errors, err) |
| 1597 |
} |
| 1598 |
oneofIdentifierPresent = true |
| 1599 |
|
| 1600 |
if all { |
| 1601 |
switch v := interface{}(m.GetHeader()).(type) { |
| 1602 |
case interface{ ValidateAll() error }: |
| 1603 |
if err := v.ValidateAll(); err != nil { |
| 1604 |
errors = append(errors, PrincipalValidationError{ |
| 1605 |
field: "Header", |
| 1606 |
reason: "embedded message failed validation", |
| 1607 |
cause: err, |
| 1608 |
}) |
| 1609 |
} |
| 1610 |
case interface{ Validate() error }: |
| 1611 |
if err := v.Validate(); err != nil { |
| 1612 |
errors = append(errors, PrincipalValidationError{ |
| 1613 |
field: "Header", |
| 1614 |
reason: "embedded message failed validation", |
| 1615 |
cause: err, |
| 1616 |
}) |
| 1617 |
} |
| 1618 |
} |
| 1619 |
} else if v, ok := interface{}(m.GetHeader()).(interface{ Validate() error }); ok { |
| 1620 |
if err := v.Validate(); err != nil { |
| 1621 |
return PrincipalValidationError{ |
| 1622 |
field: "Header", |
| 1623 |
reason: "embedded message failed validation", |
| 1624 |
cause: err, |
| 1625 |
} |
| 1626 |
} |
| 1627 |
} |
| 1628 |
|
| 1629 |
case *Principal_UrlPath: |
| 1630 |
if v == nil { |
| 1631 |
err := PrincipalValidationError{ |
| 1632 |
field: "Identifier", |
| 1633 |
reason: "oneof value cannot be a typed-nil", |
| 1634 |
} |
| 1635 |
if !all { |
| 1636 |
return err |
| 1637 |
} |
| 1638 |
errors = append(errors, err) |
| 1639 |
} |
| 1640 |
oneofIdentifierPresent = true |
| 1641 |
|
| 1642 |
if all { |
| 1643 |
switch v := interface{}(m.GetUrlPath()).(type) { |
| 1644 |
case interface{ ValidateAll() error }: |
| 1645 |
if err := v.ValidateAll(); err != nil { |
| 1646 |
errors = append(errors, PrincipalValidationError{ |
| 1647 |
field: "UrlPath", |
| 1648 |
reason: "embedded message failed validation", |
| 1649 |
cause: err, |
| 1650 |
}) |
| 1651 |
} |
| 1652 |
case interface{ Validate() error }: |
| 1653 |
if err := v.Validate(); err != nil { |
| 1654 |
errors = append(errors, PrincipalValidationError{ |
| 1655 |
field: "UrlPath", |
| 1656 |
reason: "embedded message failed validation", |
| 1657 |
cause: err, |
| 1658 |
}) |
| 1659 |
} |
| 1660 |
} |
| 1661 |
} else if v, ok := interface{}(m.GetUrlPath()).(interface{ Validate() error }); ok { |
| 1662 |
if err := v.Validate(); err != nil { |
| 1663 |
return PrincipalValidationError{ |
| 1664 |
field: "UrlPath", |
| 1665 |
reason: "embedded message failed validation", |
| 1666 |
cause: err, |
| 1667 |
} |
| 1668 |
} |
| 1669 |
} |
| 1670 |
|
| 1671 |
case *Principal_Metadata: |
| 1672 |
if v == nil { |
| 1673 |
err := PrincipalValidationError{ |
| 1674 |
field: "Identifier", |
| 1675 |
reason: "oneof value cannot be a typed-nil", |
| 1676 |
} |
| 1677 |
if !all { |
| 1678 |
return err |
| 1679 |
} |
| 1680 |
errors = append(errors, err) |
| 1681 |
} |
| 1682 |
oneofIdentifierPresent = true |
| 1683 |
|
| 1684 |
if all { |
| 1685 |
switch v := interface{}(m.GetMetadata()).(type) { |
| 1686 |
case interface{ ValidateAll() error }: |
| 1687 |
if err := v.ValidateAll(); err != nil { |
| 1688 |
errors = append(errors, PrincipalValidationError{ |
| 1689 |
field: "Metadata", |
| 1690 |
reason: "embedded message failed validation", |
| 1691 |
cause: err, |
| 1692 |
}) |
| 1693 |
} |
| 1694 |
case interface{ Validate() error }: |
| 1695 |
if err := v.Validate(); err != nil { |
| 1696 |
errors = append(errors, PrincipalValidationError{ |
| 1697 |
field: "Metadata", |
| 1698 |
reason: "embedded message failed validation", |
| 1699 |
cause: err, |
| 1700 |
}) |
| 1701 |
} |
| 1702 |
} |
| 1703 |
} else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { |
| 1704 |
if err := v.Validate(); err != nil { |
| 1705 |
return PrincipalValidationError{ |
| 1706 |
field: "Metadata", |
| 1707 |
reason: "embedded message failed validation", |
| 1708 |
cause: err, |
| 1709 |
} |
| 1710 |
} |
| 1711 |
} |
| 1712 |
|
| 1713 |
case *Principal_FilterState: |
| 1714 |
if v == nil { |
| 1715 |
err := PrincipalValidationError{ |
| 1716 |
field: "Identifier", |
| 1717 |
reason: "oneof value cannot be a typed-nil", |
| 1718 |
} |
| 1719 |
if !all { |
| 1720 |
return err |
| 1721 |
} |
| 1722 |
errors = append(errors, err) |
| 1723 |
} |
| 1724 |
oneofIdentifierPresent = true |
| 1725 |
|
| 1726 |
if all { |
| 1727 |
switch v := interface{}(m.GetFilterState()).(type) { |
| 1728 |
case interface{ ValidateAll() error }: |
| 1729 |
if err := v.ValidateAll(); err != nil { |
| 1730 |
errors = append(errors, PrincipalValidationError{ |
| 1731 |
field: "FilterState", |
| 1732 |
reason: "embedded message failed validation", |
| 1733 |
cause: err, |
| 1734 |
}) |
| 1735 |
} |
| 1736 |
case interface{ Validate() error }: |
| 1737 |
if err := v.Validate(); err != nil { |
| 1738 |
errors = append(errors, PrincipalValidationError{ |
| 1739 |
field: "FilterState", |
| 1740 |
reason: "embedded message failed validation", |
| 1741 |
cause: err, |
| 1742 |
}) |
| 1743 |
} |
| 1744 |
} |
| 1745 |
} else if v, ok := interface{}(m.GetFilterState()).(interface{ Validate() error }); ok { |
| 1746 |
if err := v.Validate(); err != nil { |
| 1747 |
return PrincipalValidationError{ |
| 1748 |
field: "FilterState", |
| 1749 |
reason: "embedded message failed validation", |
| 1750 |
cause: err, |
| 1751 |
} |
| 1752 |
} |
| 1753 |
} |
| 1754 |
|
| 1755 |
case *Principal_NotId: |
| 1756 |
if v == nil { |
| 1757 |
err := PrincipalValidationError{ |
| 1758 |
field: "Identifier", |
| 1759 |
reason: "oneof value cannot be a typed-nil", |
| 1760 |
} |
| 1761 |
if !all { |
| 1762 |
return err |
| 1763 |
} |
| 1764 |
errors = append(errors, err) |
| 1765 |
} |
| 1766 |
oneofIdentifierPresent = true |
| 1767 |
|
| 1768 |
if all { |
| 1769 |
switch v := interface{}(m.GetNotId()).(type) { |
| 1770 |
case interface{ ValidateAll() error }: |
| 1771 |
if err := v.ValidateAll(); err != nil { |
| 1772 |
errors = append(errors, PrincipalValidationError{ |
| 1773 |
field: "NotId", |
| 1774 |
reason: "embedded message failed validation", |
| 1775 |
cause: err, |
| 1776 |
}) |
| 1777 |
} |
| 1778 |
case interface{ Validate() error }: |
| 1779 |
if err := v.Validate(); err != nil { |
| 1780 |
errors = append(errors, PrincipalValidationError{ |
| 1781 |
field: "NotId", |
| 1782 |
reason: "embedded message failed validation", |
| 1783 |
cause: err, |
| 1784 |
}) |
| 1785 |
} |
| 1786 |
} |
| 1787 |
} else if v, ok := interface{}(m.GetNotId()).(interface{ Validate() error }); ok { |
| 1788 |
if err := v.Validate(); err != nil { |
| 1789 |
return PrincipalValidationError{ |
| 1790 |
field: "NotId", |
| 1791 |
reason: "embedded message failed validation", |
| 1792 |
cause: err, |
| 1793 |
} |
| 1794 |
} |
| 1795 |
} |
| 1796 |
|
| 1797 |
case *Principal_SourcedMetadata: |
| 1798 |
if v == nil { |
| 1799 |
err := PrincipalValidationError{ |
| 1800 |
field: "Identifier", |
| 1801 |
reason: "oneof value cannot be a typed-nil", |
| 1802 |
} |
| 1803 |
if !all { |
| 1804 |
return err |
| 1805 |
} |
| 1806 |
errors = append(errors, err) |
| 1807 |
} |
| 1808 |
oneofIdentifierPresent = true |
| 1809 |
|
| 1810 |
if all { |
| 1811 |
switch v := interface{}(m.GetSourcedMetadata()).(type) { |
| 1812 |
case interface{ ValidateAll() error }: |
| 1813 |
if err := v.ValidateAll(); err != nil { |
| 1814 |
errors = append(errors, PrincipalValidationError{ |
| 1815 |
field: "SourcedMetadata", |
| 1816 |
reason: "embedded message failed validation", |
| 1817 |
cause: err, |
| 1818 |
}) |
| 1819 |
} |
| 1820 |
case interface{ Validate() error }: |
| 1821 |
if err := v.Validate(); err != nil { |
| 1822 |
errors = append(errors, PrincipalValidationError{ |
| 1823 |
field: "SourcedMetadata", |
| 1824 |
reason: "embedded message failed validation", |
| 1825 |
cause: err, |
| 1826 |
}) |
| 1827 |
} |
| 1828 |
} |
| 1829 |
} else if v, ok := interface{}(m.GetSourcedMetadata()).(interface{ Validate() error }); ok { |
| 1830 |
if err := v.Validate(); err != nil { |
| 1831 |
return PrincipalValidationError{ |
| 1832 |
field: "SourcedMetadata", |
| 1833 |
reason: "embedded message failed validation", |
| 1834 |
cause: err, |
| 1835 |
} |
| 1836 |
} |
| 1837 |
} |
| 1838 |
|
| 1839 |
default: |
| 1840 |
_ = v // ensures v is used |
| 1841 |
} |
| 1842 |
if !oneofIdentifierPresent { |
| 1843 |
err := PrincipalValidationError{ |
| 1844 |
field: "Identifier", |
| 1845 |
reason: "value is required", |
| 1846 |
} |
| 1847 |
if !all { |
| 1848 |
return err |
| 1849 |
} |
| 1850 |
errors = append(errors, err) |
| 1851 |
} |
| 1852 |
|
| 1853 |
if len(errors) > 0 { |
| 1854 |
return PrincipalMultiError(errors) |
| 1855 |
} |
| 1856 |
|
| 1857 |
return nil |
| 1858 |
} |
| 1859 |
|
| 1860 |
// PrincipalMultiError is an error wrapping multiple validation errors returned |
| 1861 |
// by Principal.ValidateAll() if the designated constraints aren't met. |
| 1862 |
type PrincipalMultiError []error |
| 1863 |
|
| 1864 |
// Error returns a concatenation of all the error messages it wraps. |
| 1865 |
func (m PrincipalMultiError) Error() string { |
| 1866 |
var msgs []string |
| 1867 |
for _, err := range m { |
| 1868 |
msgs = append(msgs, err.Error()) |
| 1869 |
} |
| 1870 |
return strings.Join(msgs, "; ") |
| 1871 |
} |
| 1872 |
|
| 1873 |
// AllErrors returns a list of validation violation errors. |
| 1874 |
func (m PrincipalMultiError) AllErrors() []error { return m } |
| 1875 |
|
| 1876 |
// PrincipalValidationError is the validation error returned by |
| 1877 |
// Principal.Validate if the designated constraints aren't met. |
| 1878 |
type PrincipalValidationError struct { |
| 1879 |
field string |
| 1880 |
reason string |
| 1881 |
cause error |
| 1882 |
key bool |
| 1883 |
} |
| 1884 |
|
| 1885 |
// Field function returns field value. |
| 1886 |
func (e PrincipalValidationError) Field() string { return e.field } |
| 1887 |
|
| 1888 |
// Reason function returns reason value. |
| 1889 |
func (e PrincipalValidationError) Reason() string { return e.reason } |
| 1890 |
|
| 1891 |
// Cause function returns cause value. |
| 1892 |
func (e PrincipalValidationError) Cause() error { return e.cause } |
| 1893 |
|
| 1894 |
// Key function returns key value. |
| 1895 |
func (e PrincipalValidationError) Key() bool { return e.key } |
| 1896 |
|
| 1897 |
// ErrorName returns error name. |
| 1898 |
func (e PrincipalValidationError) ErrorName() string { return "PrincipalValidationError" } |
| 1899 |
|
| 1900 |
// Error satisfies the builtin error interface |
| 1901 |
func (e PrincipalValidationError) Error() string { |
| 1902 |
cause := "" |
| 1903 |
if e.cause != nil { |
| 1904 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 1905 |
} |
| 1906 |
|
| 1907 |
key := "" |
| 1908 |
if e.key { |
| 1909 |
key = "key for " |
| 1910 |
} |
| 1911 |
|
| 1912 |
return fmt.Sprintf( |
| 1913 |
"invalid %sPrincipal.%s: %s%s", |
| 1914 |
key, |
| 1915 |
e.field, |
| 1916 |
e.reason, |
| 1917 |
cause) |
| 1918 |
} |
| 1919 |
|
| 1920 |
var _ error = PrincipalValidationError{} |
| 1921 |
|
| 1922 |
var _ interface { |
| 1923 |
Field() string |
| 1924 |
Reason() string |
| 1925 |
Key() bool |
| 1926 |
Cause() error |
| 1927 |
ErrorName() string |
| 1928 |
} = PrincipalValidationError{} |
| 1929 |
|
| 1930 |
// Validate checks the field values on Action with the rules defined in the |
| 1931 |
// proto definition for this message. If any rules are violated, the first |
| 1932 |
// error encountered is returned, or nil if there are no violations. |
| 1933 |
func (m *Action) Validate() error { |
| 1934 |
return m.validate(false) |
| 1935 |
} |
| 1936 |
|
| 1937 |
// ValidateAll checks the field values on Action with the rules defined in the |
| 1938 |
// proto definition for this message. If any rules are violated, the result is |
| 1939 |
// a list of violation errors wrapped in ActionMultiError, or nil if none found. |
| 1940 |
func (m *Action) ValidateAll() error { |
| 1941 |
return m.validate(true) |
| 1942 |
} |
| 1943 |
|
| 1944 |
func (m *Action) validate(all bool) error { |
| 1945 |
if m == nil { |
| 1946 |
return nil |
| 1947 |
} |
| 1948 |
|
| 1949 |
var errors []error |
| 1950 |
|
| 1951 |
if utf8.RuneCountInString(m.GetName()) < 1 { |
| 1952 |
err := ActionValidationError{ |
| 1953 |
field: "Name", |
| 1954 |
reason: "value length must be at least 1 runes", |
| 1955 |
} |
| 1956 |
if !all { |
| 1957 |
return err |
| 1958 |
} |
| 1959 |
errors = append(errors, err) |
| 1960 |
} |
| 1961 |
|
| 1962 |
// no validation rules for Action |
| 1963 |
|
| 1964 |
if len(errors) > 0 { |
| 1965 |
return ActionMultiError(errors) |
| 1966 |
} |
| 1967 |
|
| 1968 |
return nil |
| 1969 |
} |
| 1970 |
|
| 1971 |
// ActionMultiError is an error wrapping multiple validation errors returned by |
| 1972 |
// Action.ValidateAll() if the designated constraints aren't met. |
| 1973 |
type ActionMultiError []error |
| 1974 |
|
| 1975 |
// Error returns a concatenation of all the error messages it wraps. |
| 1976 |
func (m ActionMultiError) Error() string { |
| 1977 |
var msgs []string |
| 1978 |
for _, err := range m { |
| 1979 |
msgs = append(msgs, err.Error()) |
| 1980 |
} |
| 1981 |
return strings.Join(msgs, "; ") |
| 1982 |
} |
| 1983 |
|
| 1984 |
// AllErrors returns a list of validation violation errors. |
| 1985 |
func (m ActionMultiError) AllErrors() []error { return m } |
| 1986 |
|
| 1987 |
// ActionValidationError is the validation error returned by Action.Validate if |
| 1988 |
// the designated constraints aren't met. |
| 1989 |
type ActionValidationError struct { |
| 1990 |
field string |
| 1991 |
reason string |
| 1992 |
cause error |
| 1993 |
key bool |
| 1994 |
} |
| 1995 |
|
| 1996 |
// Field function returns field value. |
| 1997 |
func (e ActionValidationError) Field() string { return e.field } |
| 1998 |
|
| 1999 |
// Reason function returns reason value. |
| 2000 |
func (e ActionValidationError) Reason() string { return e.reason } |
| 2001 |
|
| 2002 |
// Cause function returns cause value. |
| 2003 |
func (e ActionValidationError) Cause() error { return e.cause } |
| 2004 |
|
| 2005 |
// Key function returns key value. |
| 2006 |
func (e ActionValidationError) Key() bool { return e.key } |
| 2007 |
|
| 2008 |
// ErrorName returns error name. |
| 2009 |
func (e ActionValidationError) ErrorName() string { return "ActionValidationError" } |
| 2010 |
|
| 2011 |
// Error satisfies the builtin error interface |
| 2012 |
func (e ActionValidationError) Error() string { |
| 2013 |
cause := "" |
| 2014 |
if e.cause != nil { |
| 2015 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 2016 |
} |
| 2017 |
|
| 2018 |
key := "" |
| 2019 |
if e.key { |
| 2020 |
key = "key for " |
| 2021 |
} |
| 2022 |
|
| 2023 |
return fmt.Sprintf( |
| 2024 |
"invalid %sAction.%s: %s%s", |
| 2025 |
key, |
| 2026 |
e.field, |
| 2027 |
e.reason, |
| 2028 |
cause) |
| 2029 |
} |
| 2030 |
|
| 2031 |
var _ error = ActionValidationError{} |
| 2032 |
|
| 2033 |
var _ interface { |
| 2034 |
Field() string |
| 2035 |
Reason() string |
| 2036 |
Key() bool |
| 2037 |
Cause() error |
| 2038 |
ErrorName() string |
| 2039 |
} = ActionValidationError{} |
| 2040 |
|
| 2041 |
// Validate checks the field values on RBAC_AuditLoggingOptions with the rules |
| 2042 |
// defined in the proto definition for this message. If any rules are |
| 2043 |
// violated, the first error encountered is returned, or nil if there are no violations. |
| 2044 |
func (m *RBAC_AuditLoggingOptions) Validate() error { |
| 2045 |
return m.validate(false) |
| 2046 |
} |
| 2047 |
|
| 2048 |
// ValidateAll checks the field values on RBAC_AuditLoggingOptions with the |
| 2049 |
// rules defined in the proto definition for this message. If any rules are |
| 2050 |
// violated, the result is a list of violation errors wrapped in |
| 2051 |
// RBAC_AuditLoggingOptionsMultiError, or nil if none found. |
| 2052 |
func (m *RBAC_AuditLoggingOptions) ValidateAll() error { |
| 2053 |
return m.validate(true) |
| 2054 |
} |
| 2055 |
|
| 2056 |
func (m *RBAC_AuditLoggingOptions) validate(all bool) error { |
| 2057 |
if m == nil { |
| 2058 |
return nil |
| 2059 |
} |
| 2060 |
|
| 2061 |
var errors []error |
| 2062 |
|
| 2063 |
if _, ok := RBAC_AuditLoggingOptions_AuditCondition_name[int32(m.GetAuditCondition())]; !ok { |
| 2064 |
err := RBAC_AuditLoggingOptionsValidationError{ |
| 2065 |
field: "AuditCondition", |
| 2066 |
reason: "value must be one of the defined enum values", |
| 2067 |
} |
| 2068 |
if !all { |
| 2069 |
return err |
| 2070 |
} |
| 2071 |
errors = append(errors, err) |
| 2072 |
} |
| 2073 |
|
| 2074 |
for idx, item := range m.GetLoggerConfigs() { |
| 2075 |
_, _ = idx, item |
| 2076 |
|
| 2077 |
if all { |
| 2078 |
switch v := interface{}(item).(type) { |
| 2079 |
case interface{ ValidateAll() error }: |
| 2080 |
if err := v.ValidateAll(); err != nil { |
| 2081 |
errors = append(errors, RBAC_AuditLoggingOptionsValidationError{ |
| 2082 |
field: fmt.Sprintf("LoggerConfigs[%v]", idx), |
| 2083 |
reason: "embedded message failed validation", |
| 2084 |
cause: err, |
| 2085 |
}) |
| 2086 |
} |
| 2087 |
case interface{ Validate() error }: |
| 2088 |
if err := v.Validate(); err != nil { |
| 2089 |
errors = append(errors, RBAC_AuditLoggingOptionsValidationError{ |
| 2090 |
field: fmt.Sprintf("LoggerConfigs[%v]", idx), |
| 2091 |
reason: "embedded message failed validation", |
| 2092 |
cause: err, |
| 2093 |
}) |
| 2094 |
} |
| 2095 |
} |
| 2096 |
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
| 2097 |
if err := v.Validate(); err != nil { |
| 2098 |
return RBAC_AuditLoggingOptionsValidationError{ |
| 2099 |
field: fmt.Sprintf("LoggerConfigs[%v]", idx), |
| 2100 |
reason: "embedded message failed validation", |
| 2101 |
cause: err, |
| 2102 |
} |
| 2103 |
} |
| 2104 |
} |
| 2105 |
|
| 2106 |
} |
| 2107 |
|
| 2108 |
if len(errors) > 0 { |
| 2109 |
return RBAC_AuditLoggingOptionsMultiError(errors) |
| 2110 |
} |
| 2111 |
|
| 2112 |
return nil |
| 2113 |
} |
| 2114 |
|
| 2115 |
// RBAC_AuditLoggingOptionsMultiError is an error wrapping multiple validation |
| 2116 |
// errors returned by RBAC_AuditLoggingOptions.ValidateAll() if the designated |
| 2117 |
// constraints aren't met. |
| 2118 |
type RBAC_AuditLoggingOptionsMultiError []error |
| 2119 |
|
| 2120 |
// Error returns a concatenation of all the error messages it wraps. |
| 2121 |
func (m RBAC_AuditLoggingOptionsMultiError) Error() string { |
| 2122 |
var msgs []string |
| 2123 |
for _, err := range m { |
| 2124 |
msgs = append(msgs, err.Error()) |
| 2125 |
} |
| 2126 |
return strings.Join(msgs, "; ") |
| 2127 |
} |
| 2128 |
|
| 2129 |
// AllErrors returns a list of validation violation errors. |
| 2130 |
func (m RBAC_AuditLoggingOptionsMultiError) AllErrors() []error { return m } |
| 2131 |
|
| 2132 |
// RBAC_AuditLoggingOptionsValidationError is the validation error returned by |
| 2133 |
// RBAC_AuditLoggingOptions.Validate if the designated constraints aren't met. |
| 2134 |
type RBAC_AuditLoggingOptionsValidationError struct { |
| 2135 |
field string |
| 2136 |
reason string |
| 2137 |
cause error |
| 2138 |
key bool |
| 2139 |
} |
| 2140 |
|
| 2141 |
// Field function returns field value. |
| 2142 |
func (e RBAC_AuditLoggingOptionsValidationError) Field() string { return e.field } |
| 2143 |
|
| 2144 |
// Reason function returns reason value. |
| 2145 |
func (e RBAC_AuditLoggingOptionsValidationError) Reason() string { return e.reason } |
| 2146 |
|
| 2147 |
// Cause function returns cause value. |
| 2148 |
func (e RBAC_AuditLoggingOptionsValidationError) Cause() error { return e.cause } |
| 2149 |
|
| 2150 |
// Key function returns key value. |
| 2151 |
func (e RBAC_AuditLoggingOptionsValidationError) Key() bool { return e.key } |
| 2152 |
|
| 2153 |
// ErrorName returns error name. |
| 2154 |
func (e RBAC_AuditLoggingOptionsValidationError) ErrorName() string { |
| 2155 |
return "RBAC_AuditLoggingOptionsValidationError" |
| 2156 |
} |
| 2157 |
|
| 2158 |
// Error satisfies the builtin error interface |
| 2159 |
func (e RBAC_AuditLoggingOptionsValidationError) Error() string { |
| 2160 |
cause := "" |
| 2161 |
if e.cause != nil { |
| 2162 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 2163 |
} |
| 2164 |
|
| 2165 |
key := "" |
| 2166 |
if e.key { |
| 2167 |
key = "key for " |
| 2168 |
} |
| 2169 |
|
| 2170 |
return fmt.Sprintf( |
| 2171 |
"invalid %sRBAC_AuditLoggingOptions.%s: %s%s", |
| 2172 |
key, |
| 2173 |
e.field, |
| 2174 |
e.reason, |
| 2175 |
cause) |
| 2176 |
} |
| 2177 |
|
| 2178 |
var _ error = RBAC_AuditLoggingOptionsValidationError{} |
| 2179 |
|
| 2180 |
var _ interface { |
| 2181 |
Field() string |
| 2182 |
Reason() string |
| 2183 |
Key() bool |
| 2184 |
Cause() error |
| 2185 |
ErrorName() string |
| 2186 |
} = RBAC_AuditLoggingOptionsValidationError{} |
| 2187 |
|
| 2188 |
// Validate checks the field values on |
| 2189 |
// RBAC_AuditLoggingOptions_AuditLoggerConfig with the rules defined in the |
| 2190 |
// proto definition for this message. If any rules are violated, the first |
| 2191 |
// error encountered is returned, or nil if there are no violations. |
| 2192 |
func (m *RBAC_AuditLoggingOptions_AuditLoggerConfig) Validate() error { |
| 2193 |
return m.validate(false) |
| 2194 |
} |
| 2195 |
|
| 2196 |
// ValidateAll checks the field values on |
| 2197 |
// RBAC_AuditLoggingOptions_AuditLoggerConfig with the rules defined in the |
| 2198 |
// proto definition for this message. If any rules are violated, the result is |
| 2199 |
// a list of violation errors wrapped in |
| 2200 |
// RBAC_AuditLoggingOptions_AuditLoggerConfigMultiError, or nil if none found. |
| 2201 |
func (m *RBAC_AuditLoggingOptions_AuditLoggerConfig) ValidateAll() error { |
| 2202 |
return m.validate(true) |
| 2203 |
} |
| 2204 |
|
| 2205 |
func (m *RBAC_AuditLoggingOptions_AuditLoggerConfig) validate(all bool) error { |
| 2206 |
if m == nil { |
| 2207 |
return nil |
| 2208 |
} |
| 2209 |
|
| 2210 |
var errors []error |
| 2211 |
|
| 2212 |
if all { |
| 2213 |
switch v := interface{}(m.GetAuditLogger()).(type) { |
| 2214 |
case interface{ ValidateAll() error }: |
| 2215 |
if err := v.ValidateAll(); err != nil { |
| 2216 |
errors = append(errors, RBAC_AuditLoggingOptions_AuditLoggerConfigValidationError{ |
| 2217 |
field: "AuditLogger", |
| 2218 |
reason: "embedded message failed validation", |
| 2219 |
cause: err, |
| 2220 |
}) |
| 2221 |
} |
| 2222 |
case interface{ Validate() error }: |
| 2223 |
if err := v.Validate(); err != nil { |
| 2224 |
errors = append(errors, RBAC_AuditLoggingOptions_AuditLoggerConfigValidationError{ |
| 2225 |
field: "AuditLogger", |
| 2226 |
reason: "embedded message failed validation", |
| 2227 |
cause: err, |
| 2228 |
}) |
| 2229 |
} |
| 2230 |
} |
| 2231 |
} else if v, ok := interface{}(m.GetAuditLogger()).(interface{ Validate() error }); ok { |
| 2232 |
if err := v.Validate(); err != nil { |
| 2233 |
return RBAC_AuditLoggingOptions_AuditLoggerConfigValidationError{ |
| 2234 |
field: "AuditLogger", |
| 2235 |
reason: "embedded message failed validation", |
| 2236 |
cause: err, |
| 2237 |
} |
| 2238 |
} |
| 2239 |
} |
| 2240 |
|
| 2241 |
// no validation rules for IsOptional |
| 2242 |
|
| 2243 |
if len(errors) > 0 { |
| 2244 |
return RBAC_AuditLoggingOptions_AuditLoggerConfigMultiError(errors) |
| 2245 |
} |
| 2246 |
|
| 2247 |
return nil |
| 2248 |
} |
| 2249 |
|
| 2250 |
// RBAC_AuditLoggingOptions_AuditLoggerConfigMultiError is an error wrapping |
| 2251 |
// multiple validation errors returned by |
| 2252 |
// RBAC_AuditLoggingOptions_AuditLoggerConfig.ValidateAll() if the designated |
| 2253 |
// constraints aren't met. |
| 2254 |
type RBAC_AuditLoggingOptions_AuditLoggerConfigMultiError []error |
| 2255 |
|
| 2256 |
// Error returns a concatenation of all the error messages it wraps. |
| 2257 |
func (m RBAC_AuditLoggingOptions_AuditLoggerConfigMultiError) Error() string { |
| 2258 |
var msgs []string |
| 2259 |
for _, err := range m { |
| 2260 |
msgs = append(msgs, err.Error()) |
| 2261 |
} |
| 2262 |
return strings.Join(msgs, "; ") |
| 2263 |
} |
| 2264 |
|
| 2265 |
// AllErrors returns a list of validation violation errors. |
| 2266 |
func (m RBAC_AuditLoggingOptions_AuditLoggerConfigMultiError) AllErrors() []error { return m } |
| 2267 |
|
| 2268 |
// RBAC_AuditLoggingOptions_AuditLoggerConfigValidationError is the validation |
| 2269 |
// error returned by RBAC_AuditLoggingOptions_AuditLoggerConfig.Validate if |
| 2270 |
// the designated constraints aren't met. |
| 2271 |
type RBAC_AuditLoggingOptions_AuditLoggerConfigValidationError struct { |
| 2272 |
field string |
| 2273 |
reason string |
| 2274 |
cause error |
| 2275 |
key bool |
| 2276 |
} |
| 2277 |
|
| 2278 |
// Field function returns field value. |
| 2279 |
func (e RBAC_AuditLoggingOptions_AuditLoggerConfigValidationError) Field() string { return e.field } |
| 2280 |
|
| 2281 |
// Reason function returns reason value. |
| 2282 |
func (e RBAC_AuditLoggingOptions_AuditLoggerConfigValidationError) Reason() string { return e.reason } |
| 2283 |
|
| 2284 |
// Cause function returns cause value. |
| 2285 |
func (e RBAC_AuditLoggingOptions_AuditLoggerConfigValidationError) Cause() error { return e.cause } |
| 2286 |
|
| 2287 |
// Key function returns key value. |
| 2288 |
func (e RBAC_AuditLoggingOptions_AuditLoggerConfigValidationError) Key() bool { return e.key } |
| 2289 |
|
| 2290 |
// ErrorName returns error name. |
| 2291 |
func (e RBAC_AuditLoggingOptions_AuditLoggerConfigValidationError) ErrorName() string { |
| 2292 |
return "RBAC_AuditLoggingOptions_AuditLoggerConfigValidationError" |
| 2293 |
} |
| 2294 |
|
| 2295 |
// Error satisfies the builtin error interface |
| 2296 |
func (e RBAC_AuditLoggingOptions_AuditLoggerConfigValidationError) Error() string { |
| 2297 |
cause := "" |
| 2298 |
if e.cause != nil { |
| 2299 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 2300 |
} |
| 2301 |
|
| 2302 |
key := "" |
| 2303 |
if e.key { |
| 2304 |
key = "key for " |
| 2305 |
} |
| 2306 |
|
| 2307 |
return fmt.Sprintf( |
| 2308 |
"invalid %sRBAC_AuditLoggingOptions_AuditLoggerConfig.%s: %s%s", |
| 2309 |
key, |
| 2310 |
e.field, |
| 2311 |
e.reason, |
| 2312 |
cause) |
| 2313 |
} |
| 2314 |
|
| 2315 |
var _ error = RBAC_AuditLoggingOptions_AuditLoggerConfigValidationError{} |
| 2316 |
|
| 2317 |
var _ interface { |
| 2318 |
Field() string |
| 2319 |
Reason() string |
| 2320 |
Key() bool |
| 2321 |
Cause() error |
| 2322 |
ErrorName() string |
| 2323 |
} = RBAC_AuditLoggingOptions_AuditLoggerConfigValidationError{} |
| 2324 |
|
| 2325 |
// Validate checks the field values on Permission_Set with the rules defined in |
| 2326 |
// the proto definition for this message. If any rules are violated, the first |
| 2327 |
// error encountered is returned, or nil if there are no violations. |
| 2328 |
func (m *Permission_Set) Validate() error { |
| 2329 |
return m.validate(false) |
| 2330 |
} |
| 2331 |
|
| 2332 |
// ValidateAll checks the field values on Permission_Set with the rules defined |
| 2333 |
// in the proto definition for this message. If any rules are violated, the |
| 2334 |
// result is a list of violation errors wrapped in Permission_SetMultiError, |
| 2335 |
// or nil if none found. |
| 2336 |
func (m *Permission_Set) ValidateAll() error { |
| 2337 |
return m.validate(true) |
| 2338 |
} |
| 2339 |
|
| 2340 |
func (m *Permission_Set) validate(all bool) error { |
| 2341 |
if m == nil { |
| 2342 |
return nil |
| 2343 |
} |
| 2344 |
|
| 2345 |
var errors []error |
| 2346 |
|
| 2347 |
if len(m.GetRules()) < 1 { |
| 2348 |
err := Permission_SetValidationError{ |
| 2349 |
field: "Rules", |
| 2350 |
reason: "value must contain at least 1 item(s)", |
| 2351 |
} |
| 2352 |
if !all { |
| 2353 |
return err |
| 2354 |
} |
| 2355 |
errors = append(errors, err) |
| 2356 |
} |
| 2357 |
|
| 2358 |
for idx, item := range m.GetRules() { |
| 2359 |
_, _ = idx, item |
| 2360 |
|
| 2361 |
if all { |
| 2362 |
switch v := interface{}(item).(type) { |
| 2363 |
case interface{ ValidateAll() error }: |
| 2364 |
if err := v.ValidateAll(); err != nil { |
| 2365 |
errors = append(errors, Permission_SetValidationError{ |
| 2366 |
field: fmt.Sprintf("Rules[%v]", idx), |
| 2367 |
reason: "embedded message failed validation", |
| 2368 |
cause: err, |
| 2369 |
}) |
| 2370 |
} |
| 2371 |
case interface{ Validate() error }: |
| 2372 |
if err := v.Validate(); err != nil { |
| 2373 |
errors = append(errors, Permission_SetValidationError{ |
| 2374 |
field: fmt.Sprintf("Rules[%v]", idx), |
| 2375 |
reason: "embedded message failed validation", |
| 2376 |
cause: err, |
| 2377 |
}) |
| 2378 |
} |
| 2379 |
} |
| 2380 |
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
| 2381 |
if err := v.Validate(); err != nil { |
| 2382 |
return Permission_SetValidationError{ |
| 2383 |
field: fmt.Sprintf("Rules[%v]", idx), |
| 2384 |
reason: "embedded message failed validation", |
| 2385 |
cause: err, |
| 2386 |
} |
| 2387 |
} |
| 2388 |
} |
| 2389 |
|
| 2390 |
} |
| 2391 |
|
| 2392 |
if len(errors) > 0 { |
| 2393 |
return Permission_SetMultiError(errors) |
| 2394 |
} |
| 2395 |
|
| 2396 |
return nil |
| 2397 |
} |
| 2398 |
|
| 2399 |
// Permission_SetMultiError is an error wrapping multiple validation errors |
| 2400 |
// returned by Permission_Set.ValidateAll() if the designated constraints |
| 2401 |
// aren't met. |
| 2402 |
type Permission_SetMultiError []error |
| 2403 |
|
| 2404 |
// Error returns a concatenation of all the error messages it wraps. |
| 2405 |
func (m Permission_SetMultiError) Error() string { |
| 2406 |
var msgs []string |
| 2407 |
for _, err := range m { |
| 2408 |
msgs = append(msgs, err.Error()) |
| 2409 |
} |
| 2410 |
return strings.Join(msgs, "; ") |
| 2411 |
} |
| 2412 |
|
| 2413 |
// AllErrors returns a list of validation violation errors. |
| 2414 |
func (m Permission_SetMultiError) AllErrors() []error { return m } |
| 2415 |
|
| 2416 |
// Permission_SetValidationError is the validation error returned by |
| 2417 |
// Permission_Set.Validate if the designated constraints aren't met. |
| 2418 |
type Permission_SetValidationError struct { |
| 2419 |
field string |
| 2420 |
reason string |
| 2421 |
cause error |
| 2422 |
key bool |
| 2423 |
} |
| 2424 |
|
| 2425 |
// Field function returns field value. |
| 2426 |
func (e Permission_SetValidationError) Field() string { return e.field } |
| 2427 |
|
| 2428 |
// Reason function returns reason value. |
| 2429 |
func (e Permission_SetValidationError) Reason() string { return e.reason } |
| 2430 |
|
| 2431 |
// Cause function returns cause value. |
| 2432 |
func (e Permission_SetValidationError) Cause() error { return e.cause } |
| 2433 |
|
| 2434 |
// Key function returns key value. |
| 2435 |
func (e Permission_SetValidationError) Key() bool { return e.key } |
| 2436 |
|
| 2437 |
// ErrorName returns error name. |
| 2438 |
func (e Permission_SetValidationError) ErrorName() string { return "Permission_SetValidationError" } |
| 2439 |
|
| 2440 |
// Error satisfies the builtin error interface |
| 2441 |
func (e Permission_SetValidationError) Error() string { |
| 2442 |
cause := "" |
| 2443 |
if e.cause != nil { |
| 2444 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 2445 |
} |
| 2446 |
|
| 2447 |
key := "" |
| 2448 |
if e.key { |
| 2449 |
key = "key for " |
| 2450 |
} |
| 2451 |
|
| 2452 |
return fmt.Sprintf( |
| 2453 |
"invalid %sPermission_Set.%s: %s%s", |
| 2454 |
key, |
| 2455 |
e.field, |
| 2456 |
e.reason, |
| 2457 |
cause) |
| 2458 |
} |
| 2459 |
|
| 2460 |
var _ error = Permission_SetValidationError{} |
| 2461 |
|
| 2462 |
var _ interface { |
| 2463 |
Field() string |
| 2464 |
Reason() string |
| 2465 |
Key() bool |
| 2466 |
Cause() error |
| 2467 |
ErrorName() string |
| 2468 |
} = Permission_SetValidationError{} |
| 2469 |
|
| 2470 |
// Validate checks the field values on Principal_Set with the rules defined in |
| 2471 |
// the proto definition for this message. If any rules are violated, the first |
| 2472 |
// error encountered is returned, or nil if there are no violations. |
| 2473 |
func (m *Principal_Set) Validate() error { |
| 2474 |
return m.validate(false) |
| 2475 |
} |
| 2476 |
|
| 2477 |
// ValidateAll checks the field values on Principal_Set with the rules defined |
| 2478 |
// in the proto definition for this message. If any rules are violated, the |
| 2479 |
// result is a list of violation errors wrapped in Principal_SetMultiError, or |
| 2480 |
// nil if none found. |
| 2481 |
func (m *Principal_Set) ValidateAll() error { |
| 2482 |
return m.validate(true) |
| 2483 |
} |
| 2484 |
|
| 2485 |
func (m *Principal_Set) validate(all bool) error { |
| 2486 |
if m == nil { |
| 2487 |
return nil |
| 2488 |
} |
| 2489 |
|
| 2490 |
var errors []error |
| 2491 |
|
| 2492 |
if len(m.GetIds()) < 1 { |
| 2493 |
err := Principal_SetValidationError{ |
| 2494 |
field: "Ids", |
| 2495 |
reason: "value must contain at least 1 item(s)", |
| 2496 |
} |
| 2497 |
if !all { |
| 2498 |
return err |
| 2499 |
} |
| 2500 |
errors = append(errors, err) |
| 2501 |
} |
| 2502 |
|
| 2503 |
for idx, item := range m.GetIds() { |
| 2504 |
_, _ = idx, item |
| 2505 |
|
| 2506 |
if all { |
| 2507 |
switch v := interface{}(item).(type) { |
| 2508 |
case interface{ ValidateAll() error }: |
| 2509 |
if err := v.ValidateAll(); err != nil { |
| 2510 |
errors = append(errors, Principal_SetValidationError{ |
| 2511 |
field: fmt.Sprintf("Ids[%v]", idx), |
| 2512 |
reason: "embedded message failed validation", |
| 2513 |
cause: err, |
| 2514 |
}) |
| 2515 |
} |
| 2516 |
case interface{ Validate() error }: |
| 2517 |
if err := v.Validate(); err != nil { |
| 2518 |
errors = append(errors, Principal_SetValidationError{ |
| 2519 |
field: fmt.Sprintf("Ids[%v]", idx), |
| 2520 |
reason: "embedded message failed validation", |
| 2521 |
cause: err, |
| 2522 |
}) |
| 2523 |
} |
| 2524 |
} |
| 2525 |
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
| 2526 |
if err := v.Validate(); err != nil { |
| 2527 |
return Principal_SetValidationError{ |
| 2528 |
field: fmt.Sprintf("Ids[%v]", idx), |
| 2529 |
reason: "embedded message failed validation", |
| 2530 |
cause: err, |
| 2531 |
} |
| 2532 |
} |
| 2533 |
} |
| 2534 |
|
| 2535 |
} |
| 2536 |
|
| 2537 |
if len(errors) > 0 { |
| 2538 |
return Principal_SetMultiError(errors) |
| 2539 |
} |
| 2540 |
|
| 2541 |
return nil |
| 2542 |
} |
| 2543 |
|
| 2544 |
// Principal_SetMultiError is an error wrapping multiple validation errors |
| 2545 |
// returned by Principal_Set.ValidateAll() if the designated constraints |
| 2546 |
// aren't met. |
| 2547 |
type Principal_SetMultiError []error |
| 2548 |
|
| 2549 |
// Error returns a concatenation of all the error messages it wraps. |
| 2550 |
func (m Principal_SetMultiError) Error() string { |
| 2551 |
var msgs []string |
| 2552 |
for _, err := range m { |
| 2553 |
msgs = append(msgs, err.Error()) |
| 2554 |
} |
| 2555 |
return strings.Join(msgs, "; ") |
| 2556 |
} |
| 2557 |
|
| 2558 |
// AllErrors returns a list of validation violation errors. |
| 2559 |
func (m Principal_SetMultiError) AllErrors() []error { return m } |
| 2560 |
|
| 2561 |
// Principal_SetValidationError is the validation error returned by |
| 2562 |
// Principal_Set.Validate if the designated constraints aren't met. |
| 2563 |
type Principal_SetValidationError struct { |
| 2564 |
field string |
| 2565 |
reason string |
| 2566 |
cause error |
| 2567 |
key bool |
| 2568 |
} |
| 2569 |
|
| 2570 |
// Field function returns field value. |
| 2571 |
func (e Principal_SetValidationError) Field() string { return e.field } |
| 2572 |
|
| 2573 |
// Reason function returns reason value. |
| 2574 |
func (e Principal_SetValidationError) Reason() string { return e.reason } |
| 2575 |
|
| 2576 |
// Cause function returns cause value. |
| 2577 |
func (e Principal_SetValidationError) Cause() error { return e.cause } |
| 2578 |
|
| 2579 |
// Key function returns key value. |
| 2580 |
func (e Principal_SetValidationError) Key() bool { return e.key } |
| 2581 |
|
| 2582 |
// ErrorName returns error name. |
| 2583 |
func (e Principal_SetValidationError) ErrorName() string { return "Principal_SetValidationError" } |
| 2584 |
|
| 2585 |
// Error satisfies the builtin error interface |
| 2586 |
func (e Principal_SetValidationError) Error() string { |
| 2587 |
cause := "" |
| 2588 |
if e.cause != nil { |
| 2589 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 2590 |
} |
| 2591 |
|
| 2592 |
key := "" |
| 2593 |
if e.key { |
| 2594 |
key = "key for " |
| 2595 |
} |
| 2596 |
|
| 2597 |
return fmt.Sprintf( |
| 2598 |
"invalid %sPrincipal_Set.%s: %s%s", |
| 2599 |
key, |
| 2600 |
e.field, |
| 2601 |
e.reason, |
| 2602 |
cause) |
| 2603 |
} |
| 2604 |
|
| 2605 |
var _ error = Principal_SetValidationError{} |
| 2606 |
|
| 2607 |
var _ interface { |
| 2608 |
Field() string |
| 2609 |
Reason() string |
| 2610 |
Key() bool |
| 2611 |
Cause() error |
| 2612 |
ErrorName() string |
| 2613 |
} = Principal_SetValidationError{} |
| 2614 |
|
| 2615 |
// Validate checks the field values on Principal_Authenticated with the rules |
| 2616 |
// defined in the proto definition for this message. If any rules are |
| 2617 |
// violated, the first error encountered is returned, or nil if there are no violations. |
| 2618 |
func (m *Principal_Authenticated) Validate() error { |
| 2619 |
return m.validate(false) |
| 2620 |
} |
| 2621 |
|
| 2622 |
// ValidateAll checks the field values on Principal_Authenticated with the |
| 2623 |
// rules defined in the proto definition for this message. If any rules are |
| 2624 |
// violated, the result is a list of violation errors wrapped in |
| 2625 |
// Principal_AuthenticatedMultiError, or nil if none found. |
| 2626 |
func (m *Principal_Authenticated) ValidateAll() error { |
| 2627 |
return m.validate(true) |
| 2628 |
} |
| 2629 |
|
| 2630 |
func (m *Principal_Authenticated) validate(all bool) error { |
| 2631 |
if m == nil { |
| 2632 |
return nil |
| 2633 |
} |
| 2634 |
|
| 2635 |
var errors []error |
| 2636 |
|
| 2637 |
if all { |
| 2638 |
switch v := interface{}(m.GetPrincipalName()).(type) { |
| 2639 |
case interface{ ValidateAll() error }: |
| 2640 |
if err := v.ValidateAll(); err != nil { |
| 2641 |
errors = append(errors, Principal_AuthenticatedValidationError{ |
| 2642 |
field: "PrincipalName", |
| 2643 |
reason: "embedded message failed validation", |
| 2644 |
cause: err, |
| 2645 |
}) |
| 2646 |
} |
| 2647 |
case interface{ Validate() error }: |
| 2648 |
if err := v.Validate(); err != nil { |
| 2649 |
errors = append(errors, Principal_AuthenticatedValidationError{ |
| 2650 |
field: "PrincipalName", |
| 2651 |
reason: "embedded message failed validation", |
| 2652 |
cause: err, |
| 2653 |
}) |
| 2654 |
} |
| 2655 |
} |
| 2656 |
} else if v, ok := interface{}(m.GetPrincipalName()).(interface{ Validate() error }); ok { |
| 2657 |
if err := v.Validate(); err != nil { |
| 2658 |
return Principal_AuthenticatedValidationError{ |
| 2659 |
field: "PrincipalName", |
| 2660 |
reason: "embedded message failed validation", |
| 2661 |
cause: err, |
| 2662 |
} |
| 2663 |
} |
| 2664 |
} |
| 2665 |
|
| 2666 |
if len(errors) > 0 { |
| 2667 |
return Principal_AuthenticatedMultiError(errors) |
| 2668 |
} |
| 2669 |
|
| 2670 |
return nil |
| 2671 |
} |
| 2672 |
|
| 2673 |
// Principal_AuthenticatedMultiError is an error wrapping multiple validation |
| 2674 |
// errors returned by Principal_Authenticated.ValidateAll() if the designated |
| 2675 |
// constraints aren't met. |
| 2676 |
type Principal_AuthenticatedMultiError []error |
| 2677 |
|
| 2678 |
// Error returns a concatenation of all the error messages it wraps. |
| 2679 |
func (m Principal_AuthenticatedMultiError) Error() string { |
| 2680 |
var msgs []string |
| 2681 |
for _, err := range m { |
| 2682 |
msgs = append(msgs, err.Error()) |
| 2683 |
} |
| 2684 |
return strings.Join(msgs, "; ") |
| 2685 |
} |
| 2686 |
|
| 2687 |
// AllErrors returns a list of validation violation errors. |
| 2688 |
func (m Principal_AuthenticatedMultiError) AllErrors() []error { return m } |
| 2689 |
|
| 2690 |
// Principal_AuthenticatedValidationError is the validation error returned by |
| 2691 |
// Principal_Authenticated.Validate if the designated constraints aren't met. |
| 2692 |
type Principal_AuthenticatedValidationError struct { |
| 2693 |
field string |
| 2694 |
reason string |
| 2695 |
cause error |
| 2696 |
key bool |
| 2697 |
} |
| 2698 |
|
| 2699 |
// Field function returns field value. |
| 2700 |
func (e Principal_AuthenticatedValidationError) Field() string { return e.field } |
| 2701 |
|
| 2702 |
// Reason function returns reason value. |
| 2703 |
func (e Principal_AuthenticatedValidationError) Reason() string { return e.reason } |
| 2704 |
|
| 2705 |
// Cause function returns cause value. |
| 2706 |
func (e Principal_AuthenticatedValidationError) Cause() error { return e.cause } |
| 2707 |
|
| 2708 |
// Key function returns key value. |
| 2709 |
func (e Principal_AuthenticatedValidationError) Key() bool { return e.key } |
| 2710 |
|
| 2711 |
// ErrorName returns error name. |
| 2712 |
func (e Principal_AuthenticatedValidationError) ErrorName() string { |
| 2713 |
return "Principal_AuthenticatedValidationError" |
| 2714 |
} |
| 2715 |
|
| 2716 |
// Error satisfies the builtin error interface |
| 2717 |
func (e Principal_AuthenticatedValidationError) Error() string { |
| 2718 |
cause := "" |
| 2719 |
if e.cause != nil { |
| 2720 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 2721 |
} |
| 2722 |
|
| 2723 |
key := "" |
| 2724 |
if e.key { |
| 2725 |
key = "key for " |
| 2726 |
} |
| 2727 |
|
| 2728 |
return fmt.Sprintf( |
| 2729 |
"invalid %sPrincipal_Authenticated.%s: %s%s", |
| 2730 |
key, |
| 2731 |
e.field, |
| 2732 |
e.reason, |
| 2733 |
cause) |
| 2734 |
} |
| 2735 |
|
| 2736 |
var _ error = Principal_AuthenticatedValidationError{} |
| 2737 |
|
| 2738 |
var _ interface { |
| 2739 |
Field() string |
| 2740 |
Reason() string |
| 2741 |
Key() bool |
| 2742 |
Cause() error |
| 2743 |
ErrorName() string |
| 2744 |
} = Principal_AuthenticatedValidationError{} |