- Validate Swedish Bank Account numbers, PlusGiro, and BankGiro
- Checksum validation based on official Swedish banking documentation
- Provides detailed validation results and error reasons
- Identifies bank name, clearing number, and account number for bank accounts
- All major Swedish banks (e.g., Swedbank, SEB, Nordea, Handelsbanken, Danske Bank, Länsförsäkringar, ICA Banken, SkandiaBanken, Sparbanken Syd, Ålandsbanken, Forex Bank, etc.)
- PlusGiro accounts
- BankGiro accounts
Install via NuGet:
# .NET CLI
dotnet add package KajetanKazimierczak.SwedishBankAccountsValidate Swedish Bank Account numbers, PlusGiro and BankGiro. The account numbers are validated with checksum calculations.
bankernaskontonummeruppbyggnad_anvandarmanual_sv.pdf (2024-02-22)
Instantiate the BankAccount, PlusGiro, or BankGiro class and check the IsValid property. If the account is not valid, check the ValidationResult property for details.
var account = new BankAccount(clearingNumber, 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 also be instantiated with a full account number (clearing number and account number combined), but parsing may be incorrect for Swedbank accounts starting with 8 if the clearing number has 5 digits. Prefer the constructor above when possible.
var account = new BankAccount(fullAccountNumber);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()}");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()}");The ValidationResult property provides detailed information about why an account number is invalid, including error codes and messages (e.g., invalid length, checksum failure, etc.).
Contributions are welcome! Please open issues or submit pull requests for improvements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.