Iban.Core 1.1.0

dotnet add package Iban.Core --version 1.1.0
                    
NuGet\Install-Package Iban.Core -Version 1.1.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="Iban.Core" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Iban.Core" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Iban.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Iban.Core --version 1.1.0
                    
#r "nuget: Iban.Core, 1.1.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.
#:package Iban.Core@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Iban.Core&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Iban.Core&version=1.1.0
                    
Install as a Cake Tool

Iban.Core - IBAN Validation Library

A comprehensive IBAN (International Bank Account Number) validation library for .NET applications. This library provides robust validation, parsing, and formatting capabilities for IBANs across all supported countries.

Overview

Iban.Core is a validation component that wraps and integrates three specialized packages to provide complete IBAN validation:

  • IbanNet - High-level IBAN structure validation
  • IbanNet.Extensions.Bban - Country-specific BBAN validation and modulus checking
  • ModulusChecker.NetCore - UK-specific modulus validation rules

NuGet Package

Install via NuGet Package Manager:

dotnet add package Iban.Core

Package URL: https://www.nuget.org/packages/Iban.Core/

Features

  • ✅ Structural Validation - Validates IBAN format, length, and check digits
  • ✅ Country-Specific Rules - Enforces country-specific BBAN validation
  • ✅ UK Modulus Checking - Advanced validation for UK bank accounts
  • ✅ IBAN Parsing - Extract country code, check digits, and BBAN components
  • ✅ Flexible Input - Accepts IBANs with or without spaces, any case
  • ✅ Dependency Injection - Built for modern .NET DI containers

Quick Start

Basic Validation

using Iban.Core;

// Create validation service
var validator = new IbanValidationService();

// Simple validation
ValidationResult result = validator.Validate("GB82 WEST 1234 5698 7654 32");
if (result.IsValid)
{
    Console.WriteLine("IBAN is valid!");
}
else
{
    Console.WriteLine($"Invalid IBAN: {result.ErrorMessage}");
}

// Quick boolean check
bool isValid = validator.IsValid("GB82WEST12345698765432");

Parsing IBANs

using Iban.Core;

var validator = new IbanValidationService();

if (validator.TryParse("DE89370400440532013000", out ParsedIban? iban))
{
    Console.WriteLine($"Country: {iban.Value.Country}");           // DE
    Console.WriteLine($"Check Digits: {iban.Value.CheckDigits}");  // 89
    Console.WriteLine($"BBAN: {iban.Value.Bban}");                 // 370400440532013000
    Console.WriteLine($"Bank: {iban.Value.BankCode}");             // 37040044  (the BLZ)
    Console.WriteLine($"Identifier: {iban.Value.BankIdentifier}"); // 37040044
}

Bank and branch identifiers

ParsedIban also exposes the bank and branch sections the IBAN registry defines for the country, read from the registry's positions rather than assumed to start the BBAN:

IBAN BankCode BranchCode BankIdentifier
DE89 3704 0044 … 37040044 (BLZ) — 37040044
GB29 NWBK 6016 13 … NWBK 601613 (sort code) NWBK601613
IT60 X054 2811 101 … 05428 (ABI, after the CIN) 11101 (CAB) 0542811101
PL61 1090 1014 … — 10901014 (routing number) 10901014

BankIdentifier is the contiguous span a bank directory is keyed on — bank and branch together where both exist, whichever exists otherwise. It tells you where the identifier is, not whether the bank exists: resolving it to a name or a BIC is a lookup against data that changes (a registry snapshot, a provider's directory) and is deliberately left to the caller.

Advanced Validation with Account Checking

For countries with account-level validation support (e.g., UK modulus checking):

// Performs structural + account-level validation
ValidationResult result = validator.ValidateWithAccountCheck("GB82WEST12345698765432");

Dependency Injection

Register with ASP.NET Core DI container:

using Iban.Core;
using Microsoft.Extensions.DependencyInjection;

services.AddScoped<IIbanValidationService, IbanValidationService>();

Then inject into your services:

public class BankAccountService
{
    private readonly IIbanValidationService _ibanValidator;

    public BankAccountService(IIbanValidationService ibanValidator)
    {
        _ibanValidator = ibanValidator;
    }

    public bool ValidateAccount(string iban)
    {
        var result = _ibanValidator.Validate(iban);
        return result.IsValid;
    }
}

API Reference

IIbanValidationService Interface

public interface IIbanValidationService
{
    /// <summary>
    /// Validates the provided IBAN with detailed results.
    /// </summary>
    ValidationResult Validate(string? iban);

    /// <summary>
    /// Quick boolean validation check.
    /// </summary>
    bool IsValid(string? iban);

    /// <summary>
    /// Attempts to parse IBAN into structured format.
    /// </summary>
    bool TryParse(string? iban, out ParsedIban? parsedIban);

    /// <summary>
    /// Validates with account-level checking (UK modulus, etc.).
    /// Falls back to structural validation for unsupported countries.
    /// </summary>
    ValidationResult ValidateWithAccountCheck(string? iban);
}

ValidationResult

public readonly record struct ValidationResult
{
    public bool IsValid { get; init; }
    public IbanValidationError? ErrorCode { get; init; }  // structured error code (null when valid)
    public string? ErrorMessage { get; init; }
    public string? Country { get; init; }                 // ISO 3166-1 alpha-2 country code
    public ValidationLevel Level { get; init; }           // validation actually performed
    public ValidationLevel SupportedLevel { get; init; }  // validation available for this country

    // Instances are produced via the factory methods:
    public static ValidationResult Success(string? country = null, ...);
    public static ValidationResult Failed(IbanValidationError errorCode, string errorMessage, ...);
}

ParsedIban

public readonly record struct ParsedIban
{
    public required string Country { get; init; }        // ISO 3166-1 alpha-2 country code
    public required string CheckDigits { get; init; }    // Two-digit check digits
    public required string Bban { get; init; }           // Basic Bank Account Number
    public required string NormalizedIban { get; init; } // Uppercase, no spaces
}

Use Cases

Payment Systems Integration

public class PaymentValidator
{
    private readonly IIbanValidationService _validator;

    public ValidationResult ValidateIbanBeneficiary(string iban, string countryCode)
    {
        // Validate IBAN structure
        var result = _validator.Validate(iban);
        if (!result.IsValid)
            return result;

        // Extract country from IBAN and verify it matches expected country
        if (_validator.TryParse(iban, out ParsedIban? parsed))
        {
            if (parsed!.Value.Country != countryCode)
            {
                return ValidationResult.Failed(
                    IbanValidationError.ERR_FORMAT_COUNTRY_INVALID,
                    "IBAN country code doesn't match beneficiary country");
            }
        }

        return result;
    }
}

SEPA Payment Validation

Ensure IBANs are from SEPA-participating countries:

private static readonly HashSet<string> SepaCountries = new()
{
    "AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR",
    "DE", "GR", "HU", "IS", "IE", "IT", "LV", "LI", "LT", "LU",
    "MT", "MC", "NL", "NO", "PL", "PT", "RO", "SM", "SK", "SI",
    "ES", "SE", "CH", "GB"
};

public bool IsSepaIban(string iban)
{
    if (!_validator.TryParse(iban, out ParsedIban? parsed))
        return false;

    return SepaCountries.Contains(parsed!.Value.Country);
}

Supported IBAN Countries

The library supports IBANs from 70+ countries including:

  • 🇬🇧 United Kingdom (with advanced modulus checking)
  • 🇩🇪 Germany
  • 🇫🇷 France
  • 🇮🇹 Italy
  • 🇪🇸 Spain
  • 🇳🇱 Netherlands
  • And 60+ more countries...

Testing

The library is thoroughly tested with:

  • Unit tests for all validation methods
  • Country-specific test cases
  • Edge cases (null, empty, malformed IBANs)
  • Real-world IBAN examples

Requirements

  • .NET 8.0 or later
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 1,396 9/11/2026
1.0.2 1,664 6/17/2026
1.0.1 1,116 4/1/2026
1.0.0 8,270 11/18/2025