TPCWare.IbanValidator 1.1.0

Library to validate for IBAN codes of the UE countries and the United Kingdom.
See the repository readme to contribute and expand 'IBAN format by country' list.

Install-Package TPCWare.IbanValidator -Version 1.1.0
dotnet add package TPCWare.IbanValidator --version 1.1.0
<PackageReference Include="TPCWare.IbanValidator" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TPCWare.IbanValidator --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TPCWare.IbanValidator, 1.1.0"
For F# scripts that support #r syntax, copy this into the source code to reference the package.

IBAN validator

Simple IBAN Validator

This library contains a static class IbanValidator with two static methods:

  • bool IsValid(string iban)
  • (bool isValid, int errorCode, string errorMsg) Check(string iban)

In the static class an internally used list IbanCountryFormats of IbanCountryFormat items describe the lenght and format of the IBAN code for each supported country.

Contribution

Actually I've managed to add support for IBAN codes of the UE countries and the United Kingdom.
Please feel free to contribute to add more countries, deriving the Regex expression from the Wikipedia IBAN formats by country table.

Excerpt from the code

public static class IbanValidator
{
    public static bool IsValid(string iban)
    {
        (bool isValid, _, _) = Check(iban);
        return isValid;
    }

    public static (bool isValid, int errorCode, string errorMsg) Check(string iban)
    {
        // Check IBAN code format
        ...
    
        // Calculate and verify IBAN code checksum 
        ...
    
        return (isValid, errorCode, errorMsg);
    }

    public static List<IbanCountryFormat> IbanCountryFormats = new List<IbanCountryFormat>
    {
        new IbanCountryFormat
        {
            CountryName = "Austria",
            CountryIsoCode = "AT",
            IbanRegex = @"AT\d{2}\d{16}" // 16n
        },
        
        // Other country formats
        ...
    };
}

IBAN validator

Simple IBAN Validator

This library contains a static class IbanValidator with two static methods:

  • bool IsValid(string iban)
  • (bool isValid, int errorCode, string errorMsg) Check(string iban)

In the static class an internally used list IbanCountryFormats of IbanCountryFormat items describe the lenght and format of the IBAN code for each supported country.

Contribution

Actually I've managed to add support for IBAN codes of the UE countries and the United Kingdom.
Please feel free to contribute to add more countries, deriving the Regex expression from the Wikipedia IBAN formats by country table.

Excerpt from the code

public static class IbanValidator
{
    public static bool IsValid(string iban)
    {
        (bool isValid, _, _) = Check(iban);
        return isValid;
    }

    public static (bool isValid, int errorCode, string errorMsg) Check(string iban)
    {
        // Check IBAN code format
        ...
    
        // Calculate and verify IBAN code checksum 
        ...
    
        return (isValid, errorCode, errorMsg);
    }

    public static List<IbanCountryFormat> IbanCountryFormats = new List<IbanCountryFormat>
    {
        new IbanCountryFormat
        {
            CountryName = "Austria",
            CountryIsoCode = "AT",
            IbanRegex = @"AT\d{2}\d{16}" // 16n
        },
        
        // Other country formats
        ...
    };
}

Release Notes

This version add 'IsValid' method to get only le boolean result without error type and reason message of a failed validation. It also replace integer ErrorCode in favour of enum errorType.

  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.1.0 134 4/20/2020
1.0.0 121 4/19/2020