IbanNet 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package IbanNet --version 2.0.0
NuGet\Install-Package IbanNet -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IbanNet" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IbanNet --version 2.0.0
#r "nuget: IbanNet, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install IbanNet as a Cake Addin
#addin nuget:?package=IbanNet&version=2.0.0

// Install IbanNet as a Cake Tool
#tool nuget:?package=IbanNet&version=2.0.0

Build status NuGet

IbanNet

IbanNet is a .NET library providing functionality to validate and parse an International Bank Account Number also known as IBAN.

Supported regions

Usage

Parse

The simplest way to use this library is to use the static Parse method:

Iban iban = Iban.Parse("NL91ABNA0417164300");

When parsing fails, an IbanFormatException is thrown, which contains a property Result which indicates the type of error that occurred.

TryParse

To parse an IBAN without throwing an exception use TryParse.

Iban iban;
bool success = Iban.TryParse("NL91ABNA0417164300", out iban);

The only downside is there is no way to retrieve the type of validation error that occurred if parsing fails.

IbanValidator

Lastly, you can use the validator directly:

IIbanValidator validator = new IbanValidator();
IbanValidationResult validationResult = validator.Validate("NL91ABNA041716430");

The benefit of using the validator is that it implements the IIbanValidator interface. This allows for mocking and using a DI container. It is recommended that when you do, that you cache the validator or register it as a singleton, since the initialization - although not much - does introduce some overhead when initializing the IBAN validation rules.

Iban type

Iban.Parse and Iban.TryParse return a type Iban. The Iban type is entirely optional, and if you use the validator directly you won't ever need to use this type.

However, this type does provide some useful features:

Format IBAN

To convert an Iban type to a string, call the ToString(string format) method with either of 2 formats:

Format Result
"F" or IbanNet.Iban.Formats.Flat NL91ABNA0417164300
"S" or IbanNet.Iban.Formats.Partitioned NL91 ABNA 0417 1643 00

If ToString() is called without format, defaults to 'F'.

Equals

Whether you parsed NL91 ABNA 0417 1643 00 or NL91ABNA0417164300, these IBAN are considered equal.

Mocking the static Parse/TryParse methods

If you use the static methods because you would like to use the Iban type, you can still mock the underlying validator for testing purposes by setting the static property Iban.Validator.

Installation

Install IbanNet via NuGet.

Visual Studio / .NET Framework
Install-Package IbanNet
.NET CLI
dotnet add package IbanNet

Future enhancements

  • Add support for conversion from BBAN to IBAN via 3rd party API's.
Supported .NET targets
  • .NET 4.5 or greater
  • .NET Standard 1.2 or greater
Requirements
  • Visual Studio 2017
  • .NET Core 2.0 SDK
Contributions

PR's are welcome. Please rebase before submitting, provide test coverage, and ensure the AppVeyor build passes. I will not consider PR's otherwise.

Contributors
  • skwas (author/maintainer)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.2 is compatible.  netstandard1.3 was computed.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 was computed.  netstandard2.1 was computed. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Windows Phone wpa81 was computed. 
Windows Store netcore451 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (8)

Showing the top 5 NuGet packages that depend on IbanNet:

Package Downloads
IbanNet.FluentValidation

FluentValidation support to validate IBAN user input.

IbanNet.DependencyInjection.ServiceProvider

Microsoft.Extensions.DependencyInjection integration for IbanNet; IbanNet provides an IBAN validator and parser.

DTF.Common.V2

Digital Tax Free basic models and abstractions.

IbanNet.DataAnnotations

Data annotations to validate IBAN user input.

IbanNet.DependencyInjection.Autofac

Autofac IoC container integration for IbanNet; IbanNet provides an IBAN validator and parser.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on IbanNet:

Repository Stars
skwasjer/IbanNet
C# .NET IBAN validator, parser, builder and generator
Version Downloads Last updated
5.14.0 110,874 1/20/2024
5.13.0 49,357 12/21/2023
5.12.0 113,103 10/20/2023
5.11.0 64,737 8/30/2023
5.10.0 70,574 7/15/2023
5.9.0 142,344 5/20/2023
5.8.1 188,725 4/15/2023
5.8.0 139,785 2/2/2023
5.7.2 75,284 1/1/2023
5.7.1 119,193 11/4/2022
5.7.0 64,318 10/9/2022
5.6.2 76,000 10/2/2022
5.6.1 125,811 7/22/2022
5.6.0 17,235 7/9/2022
5.5.1 24,025 6/23/2022
5.5.0 121,755 5/12/2022
5.4.0 326,881 12/31/2021
5.3.2 15,240 12/18/2021
5.3.1 62,541 11/14/2021
5.3.0 2,408 11/13/2021
5.2.0 8,913 11/10/2021
5.1.0 59,320 9/27/2021
5.0.0 27,741 8/21/2021
5.0.0-beta0001 2,056 6/17/2021
4.4.3 10,786 8/21/2021
4.4.2 78,181 6/17/2021
4.4.1 8,934 6/13/2021
4.4.0 3,474 6/12/2021
4.3.1 47,652 6/5/2021
4.3.0 295,594 11/27/2020
4.2.0 19,456 11/7/2020
4.1.0 72,329 8/8/2020
4.0.1 161,247 5/12/2020
4.0.0 93,052 2/8/2020
4.0.0-beta0241 2,129 2/8/2020
4.0.0-beta0227 1,487 2/8/2020
4.0.0-beta0223 2,492 2/8/2020
4.0.0-beta0222 1,718 2/8/2020
4.0.0-beta0204 1,554 2/6/2020
4.0.0-beta0190 1,596 1/14/2020
4.0.0-beta0187 2,532 1/13/2020
4.0.0-beta0186 1,519 1/13/2020
4.0.0-beta0183 1,560 1/13/2020
4.0.0-beta0178 27,165 12/30/2019
4.0.0-beta0177 1,553 12/29/2019
4.0.0-beta0172 1,582 12/29/2019
3.2.2 2,328 5/12/2020
3.2.1 40,218 1/14/2020
3.2.0 81,366 11/23/2019
3.1.2 2,719 10/25/2019
3.1.1 33,664 7/25/2019
3.1.0 22,718 5/10/2019
3.0.0 36,515 2/14/2019
2.1.0 27,069 9/18/2018
2.0.0 14,510 2/3/2018
1.2.0 1,855 12/25/2017
1.1.16 1,745 12/25/2017
1.0.19 1,889 12/25/2017
1.0.18 1,667 12/25/2017
1.0.17 2,336 12/25/2017