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