Skip to content

IBANValidator Class

The IBANValidator class provides methods to validate International Bank Account Numbers (IBANs).

Methods

IsValidIBAN

csharp
public static bool IsValidIBAN(string iban)

The IsValidIBAN method validates whether the given string is a valid IBAN, formatted correctly, and follows the ISO 13616 standard.

Parameters

  • iban (string): The IBAN to be validated.

Returns

  • true if the IBAN is valid.
  • false if the IBAN is not valid.

Remarks

  • The IBAN must not be null, empty, or contain only whitespace characters.
  • The method removes spaces and converts the IBAN to uppercase before validation.
  • The IBAN must have the correct length for its country code.
  • The IBAN must contain only alphanumeric characters (letters A-Z, numbers 0-9).
  • The IBAN must pass the ISO 13616 check, which involves rearranging and converting letters to corresponding numbers.

IsValidCountryCode

csharp
public static bool IsValidCountryCode(string iban)

The IsValidCountryCode method validates whether the given IBAN has a valid country code according to the ISO 3166-1 alpha-2 standard.

Reveal supported countries
Country NameCountry CodeSEPA MemberIBAN LengthIBAN Example (printed format)
AlbaniaAL28AL47 2121 1009 0000 0002 3569 8741
AndorraAD24AD12 0001 2030 2003 5910 0100
AustriaAT20AT61 1904 3002 3457 3201
AzerbaijanAZ28AZ21 NABZ 0000 0000 1370 1000 1944
BahrainBH22BH67 BMAG 0000 1299 1234 56
BelarusBY28BY13 NBRB 3600 9000 0000 2Z00 AB00
BelgiumBE16BE68 5390 0754 7034
Bosnia and HerzegovinaBA20BA39 1290 0794 0102 8494
BrazilBR29BR18 0036 0305 0000 1000 9795 493C 1
BulgariaBG22BG80 BNBG 9661 1020 3456 78
Costa RicaCR22CR05 0152 0200 1026 2840 66
CroatiaHR21HR12 1001 0051 8630 0016 0
CyprusCY28CY17 0020 0128 0000 0012 0052 7600
CzechiaCZ24CZ65 0800 0000 1920 0014 5399
DenmarkDK18DK50 0040 0440 1162 43
Dominican RepublicDO28DO28 BAGR 0000 0001 2124 5361 1324
El SalvadorSV28SV 62 CENR 00000000000000700025
EstoniaEE20EE38 2200 2210 2014 5685
Faroe IslandsFO18FO62 6460 0001 6316 34
FinlandFI18FI21 1234 5600 0007 85
FranceFR27FR14 2004 1010 0505 0001 3M02 606
GeorgiaGE22GE29 NB00 0000 0101 9049 17
GermanyDE22DE89 3704 0044 0532 0130 00
GibraltarGI23GI75 NWBK 0000 0000 7099 453
GreeceGR27GR16 0110 1250 0000 0001 2300 695
GreenlandGL18GL89 6471 0001 0002 06
GuatemalaGT28GT82 TRAJ 0102 0000 0012 1002 9690
HungaryHU28HU42 1177 3016 1111 1018 0000 0000
IcelandIS26IS14 0159 2600 7654 5510 7303 39
IraqIQ23IQ98 NBIQ 8501 2345 6789 012
IrelandIE22IE29 AIBK 9311 5212 3456 78
IsraelIL23IL62 0108 0000 0009 9999 999
ItalyIT27IT60 X054 2811 1010 0000 0123 456
JordanJO30JO94 CBJO 0010 0000 0000 0131 000302
KazakhstanKZ20KZ86 125K ZT50 0410 0100
KosovoXK20XK05 1212 0123 4567 8906
KuwaitKW30KW81 CBKU 0000 0000 0000 1234 560101
LatviaLV21LV80 BANK 0000 4351 9500 1
LebanonLB28LB62 0999 0000 0001 0019 0122 9114
LiechtensteinLI21LI21 0881 0000 2324 013A A
LithuaniaLT20LT12 1000 0111 0100 1000
LuxembourgLU20LU28 0019 4006 4475 0000
MacedoniaMK19MK07 2501 2000 0058 984
MaltaMT31MT84 MALT 0110 0001 2345 MTLC AST0 01S
MauritaniaMR27MR13 0002 0001 0100 0012 3456 753
MauritiusMU30MU17 BOMM 0101 1010 3030 0200 000M UR
MoldovaMD24MD24 AG00 0225 1000 1310 4168
MonacoMC27MC58 1122 2000 0101 2345 6789 030
MontenegroME22ME25 5050 0001 2345 6789 51
NetherlandsNL18NL91 ABNA 0417 1643 00
NorwayNO15NO93 8601 1117 947
PakistanPK24PK36 SCBL 0000 0011 2345 6702
PalestinePS29PS92 PALS 0000 0000 0400 1234 5670 2
PolandPL28PL61 1090 1014 0000 0712 1981 2874
PortugalPT25PT50 0002 0123 1234 5678 9015 4
QatarQA29QA58 DOHB 0000 1234 5678 90AB CDEF G
RomaniaRO24RO49 AAAA 1B31 0075 9384 0000
Saint LuciaLC32LC55 HEMM 0001 0001 0012 0012 00023015
San MarinoSM27SM86 U032 2509 8000 0000 0270 100
Sao Tome and PrincipeST25ST68 0002 0001 0192 1942 1011 2
Saudi ArabiaSA24SA03 8000 0000 6080 1016 7519
SerbiaRS22RS35 2600 0560 1001 6113 79
SeychellesSC31SC18 SSCB 1101 0000 0000 0000 1497 USD
SlovakiaSK24SK31 1200 0000 1987 4263 7541
SloveniaSI19SI56 2633 0001 2039 086
SpainES24ES91 2100 0418 4502 0005 1332
SwedenSE24SE45 5000 0000 0583 9825 7466
SwitzerlandCH21CH93 0076 2011 6238 5295 7
Timor-LesteTL23TL38 0080 0123 4567 8910 157
TunisiaTN24TN59 1000 6035 1835 9847 8831
TurkeyTR26TR33 0006 1005 1978 6457 8413 26
UkraineUA29UA21 3223 1300 0002 6007 2335 6600 1
United Arab EmiratesAE23AE07 0331 2345 6789 0123 456
United KingdomGB22GB29 NWBK 6016 1331 9268 19
Vatican City StateVA22VA59 001 1230 0001 2345 678
Virgin IslandsVG24VG96 VPVG 0000 0123 4567 8901

Parameters

  • iban (string): The IBAN to be validated.

Returns

  • true if the country code in the IBAN is valid.
  • false if the country code in the IBAN is not valid.

Remarks

  • The method checks the first two characters of the IBAN to identify the country code.
  • The IBAN's country code must match one of the valid country codes based on the ISO 3166-1 alpha-2 standard.

Example

csharp
using XValid;

string iban = "GB29 NWBK 6016 1331 9268 19"; // Example IBAN (United Kingdom)
bool isValid = IBANValidator.IsValidIBAN(iban);

if (isValid)
{
    Console.WriteLine("Valid IBAN!");
}
else
{
    Console.WriteLine("Invalid IBAN!");
}

That's it! You can use the IBANValidator class in your C# code to validate International Bank Account Numbers (IBANs) based on the defined checks and ISO standards. If you have any questions or need more information, feel free to explore other sections of the API reference or check out the Get Started page for an overview of XValid.

Released under the MIT License.