(dest interface{}, inter interface{}, v *InterfaceStructListValidation)
| 525 | } |
| 526 | |
| 527 | func InterfaceStructList(dest interface{}, inter interface{}, v *InterfaceStructListValidation) (interface{}, []error) { |
| 528 | if inter == nil { |
| 529 | if v.TreatNullAsEmpty { |
| 530 | inter = make([]interface{}, 0) |
| 531 | } else { |
| 532 | if !v.AllowExplicitNull { |
| 533 | return nil, []error{ErrorCannotBeEmptyOrNull(v.Required)} |
| 534 | } |
| 535 | return nil, nil |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | interSlice, ok := cast.InterfaceToInterfaceSlice(inter) |
| 540 | if !ok { |
| 541 | return nil, []error{ErrorInvalidPrimitiveType(inter, PrimTypeList)} |
| 542 | } |
| 543 | |
| 544 | errs := []error{} |
| 545 | for i, interItem := range interSlice { |
| 546 | val, subErrs := InterfaceStruct(interItem, v.InterfaceStructValidation) |
| 547 | var ok bool |
| 548 | if errs, ok = errors.AddErrors(errs, subErrs, s.Index(i)); ok { |
| 549 | if v.ShortCircuit { |
| 550 | return nil, errs |
| 551 | } |
| 552 | continue |
| 553 | } |
| 554 | dest = appendVal(dest, val) |
| 555 | } |
| 556 | |
| 557 | return dest, errs |
| 558 | } |
| 559 | |
| 560 | func updateValidation(validation interface{}, dest interface{}, structFieldValidation *StructFieldValidation) { |
| 561 | if structFieldValidation.DefaultField != "" { |
no test coverage detected