Skip to content

Commit

Permalink
Refactor Beneficiary Account Numbers Validation (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbengfort authored Oct 31, 2023
1 parent 80390c2 commit cc4af04
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pkg/rvasp/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,23 @@ func ValidateIdentityPayload(identity *ivms101.IdentityPayload, requireBeneficia
}

// Check that the account number is present
if len(identity.Beneficiary.AccountNumbers) == 0 || identity.Beneficiary.AccountNumbers[0] == "" {
log.Warn().Msg("identity payload missing account number")
if len(identity.Beneficiary.AccountNumbers) == 0 {
log.Warn().Msg("identity payload missing beneficiary account number")
return protocol.Errorf(protocol.IncompleteIdentity, "missing beneficiary account number")
} else {
// Verify that there is at least one valid account number
foundValid := false
for _, accountNumber := range identity.Beneficiary.AccountNumbers {
if accountNumber != "" {
foundValid = true
break
}
}

if !foundValid {
log.Warn().Strs("account_numbers", identity.Beneficiary.AccountNumbers).Msg("no valid beneficiary account numbers")
return protocol.Errorf(protocol.IncompleteIdentity, "no valid beneficiary account number(s) found")
}
}

// Check that the beneficiary vasp is present
Expand Down

0 comments on commit cc4af04

Please sign in to comment.