Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Beneficiary Account Numbers Validation #156

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading