SwedishBankAccounts
Info
Validate Swedish Bank Account numbers, PlusGiro and BankGiro. The account numbers are validated with checksum calculations.
Based on
bankernaskontonummeruppbyggnad_anvandarmanual_sv.pdf (2022-12-13)
Usage
Instantiate the BankAccount, PlusGiro or BankGiro class and check the IsValid property of the object. If the account is not valid, check the ValidationResult property for details.
Examples
Bank account
var account = new BankAccount(clearigNumber, accountNumber);
if (!account.IsValid)
{
Console.WriteLine("Account number invalid");
Console.WriteLine($"Reason: {account.ValidationResult.ToString()}");
return;
}
Console.WriteLine("Account number valid");
Console.WriteLine($"Validation result: {account.ValidationResult.ToString()}");
Console.WriteLine($"Bank: {account.BankName}");
Console.WriteLine($"Clearing number: {account.ClearingNumber}");
Console.WriteLine($"Account number: {account.AccountNumber}");
The BankAccount class can be instantiated with full account number (clearing number and account number combined), but the parsing could be wrong for Swedbank accounts starting with an 8 if the clearing number has 5 digits. If possible, use the above constructor.
var account = new BankAccount(fullAccountNumber);
PlusGiro
var account = new PlusGiro(accountNumber);
if (!account.IsValid)
{
Console.WriteLine("Account number invalid");
Console.WriteLine($"Reason: {account.ValidationResult.ToString()}");
return;
}
Console.WriteLine("Account number valid");
Console.WriteLine($"Validation result: {account.ValidationResult.ToString()}");
BankGiro
var account = new BankGiro(accountNumber);
if (!account.IsValid)
{
Console.WriteLine("Account number invalid");
Console.WriteLine($"Reason: {account.ValidationResult.ToString()}");
return;
}
Console.WriteLine("Account number valid");
Console.WriteLine($"Validation result: {account.ValidationResult.ToString()}");
Known issues
In rare occasions some of Swedbank’s accounts with clearing number beginning with '8' cannot be validated by a checksum calculation. These accounts will be flagged as invalid.