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 Name | Country Code | SEPA Member | IBAN Length | IBAN Example (printed format) |
---|---|---|---|---|
Albania | AL | 28 | AL47 2121 1009 0000 0002 3569 8741 | |
Andorra | AD | 24 | AD12 0001 2030 2003 5910 0100 | |
Austria | AT | ✔ | 20 | AT61 1904 3002 3457 3201 |
Azerbaijan | AZ | 28 | AZ21 NABZ 0000 0000 1370 1000 1944 | |
Bahrain | BH | 22 | BH67 BMAG 0000 1299 1234 56 | |
Belarus | BY | 28 | BY13 NBRB 3600 9000 0000 2Z00 AB00 | |
Belgium | BE | ✔ | 16 | BE68 5390 0754 7034 |
Bosnia and Herzegovina | BA | 20 | BA39 1290 0794 0102 8494 | |
Brazil | BR | 29 | BR18 0036 0305 0000 1000 9795 493C 1 | |
Bulgaria | BG | ✔ | 22 | BG80 BNBG 9661 1020 3456 78 |
Costa Rica | CR | 22 | CR05 0152 0200 1026 2840 66 | |
Croatia | HR | ✔ | 21 | HR12 1001 0051 8630 0016 0 |
Cyprus | CY | ✔ | 28 | CY17 0020 0128 0000 0012 0052 7600 |
Czechia | CZ | ✔ | 24 | CZ65 0800 0000 1920 0014 5399 |
Denmark | DK | ✔ | 18 | DK50 0040 0440 1162 43 |
Dominican Republic | DO | 28 | DO28 BAGR 0000 0001 2124 5361 1324 | |
El Salvador | SV | 28 | SV 62 CENR 00000000000000700025 | |
Estonia | EE | ✔ | 20 | EE38 2200 2210 2014 5685 |
Faroe Islands | FO | 18 | FO62 6460 0001 6316 34 | |
Finland | FI | ✔ | 18 | FI21 1234 5600 0007 85 |
France | FR | ✔ | 27 | FR14 2004 1010 0505 0001 3M02 606 |
Georgia | GE | 22 | GE29 NB00 0000 0101 9049 17 | |
Germany | DE | ✔ | 22 | DE89 3704 0044 0532 0130 00 |
Gibraltar | GI | ✔ | 23 | GI75 NWBK 0000 0000 7099 453 |
Greece | GR | ✔ | 27 | GR16 0110 1250 0000 0001 2300 695 |
Greenland | GL | 18 | GL89 6471 0001 0002 06 | |
Guatemala | GT | 28 | GT82 TRAJ 0102 0000 0012 1002 9690 | |
Hungary | HU | ✔ | 28 | HU42 1177 3016 1111 1018 0000 0000 |
Iceland | IS | ✔ | 26 | IS14 0159 2600 7654 5510 7303 39 |
Iraq | IQ | 23 | IQ98 NBIQ 8501 2345 6789 012 | |
Ireland | IE | ✔ | 22 | IE29 AIBK 9311 5212 3456 78 |
Israel | IL | 23 | IL62 0108 0000 0009 9999 999 | |
Italy | IT | ✔ | 27 | IT60 X054 2811 1010 0000 0123 456 |
Jordan | JO | 30 | JO94 CBJO 0010 0000 0000 0131 000302 | |
Kazakhstan | KZ | 20 | KZ86 125K ZT50 0410 0100 | |
Kosovo | XK | 20 | XK05 1212 0123 4567 8906 | |
Kuwait | KW | 30 | KW81 CBKU 0000 0000 0000 1234 560101 | |
Latvia | LV | ✔ | 21 | LV80 BANK 0000 4351 9500 1 |
Lebanon | LB | 28 | LB62 0999 0000 0001 0019 0122 9114 | |
Liechtenstein | LI | ✔ | 21 | LI21 0881 0000 2324 013A A |
Lithuania | LT | ✔ | 20 | LT12 1000 0111 0100 1000 |
Luxembourg | LU | ✔ | 20 | LU28 0019 4006 4475 0000 |
Macedonia | MK | 19 | MK07 2501 2000 0058 984 | |
Malta | MT | ✔ | 31 | MT84 MALT 0110 0001 2345 MTLC AST0 01S |
Mauritania | MR | 27 | MR13 0002 0001 0100 0012 3456 753 | |
Mauritius | MU | 30 | MU17 BOMM 0101 1010 3030 0200 000M UR | |
Moldova | MD | 24 | MD24 AG00 0225 1000 1310 4168 | |
Monaco | MC | ✔ | 27 | MC58 1122 2000 0101 2345 6789 030 |
Montenegro | ME | 22 | ME25 5050 0001 2345 6789 51 | |
Netherlands | NL | ✔ | 18 | NL91 ABNA 0417 1643 00 |
Norway | NO | ✔ | 15 | NO93 8601 1117 947 |
Pakistan | PK | 24 | PK36 SCBL 0000 0011 2345 6702 | |
Palestine | PS | 29 | PS92 PALS 0000 0000 0400 1234 5670 2 | |
Poland | PL | ✔ | 28 | PL61 1090 1014 0000 0712 1981 2874 |
Portugal | PT | ✔ | 25 | PT50 0002 0123 1234 5678 9015 4 |
Qatar | QA | 29 | QA58 DOHB 0000 1234 5678 90AB CDEF G | |
Romania | RO | ✔ | 24 | RO49 AAAA 1B31 0075 9384 0000 |
Saint Lucia | LC | 32 | LC55 HEMM 0001 0001 0012 0012 00023015 | |
San Marino | SM | ✔ | 27 | SM86 U032 2509 8000 0000 0270 100 |
Sao Tome and Principe | ST | 25 | ST68 0002 0001 0192 1942 1011 2 | |
Saudi Arabia | SA | 24 | SA03 8000 0000 6080 1016 7519 | |
Serbia | RS | 22 | RS35 2600 0560 1001 6113 79 | |
Seychelles | SC | 31 | SC18 SSCB 1101 0000 0000 0000 1497 USD | |
Slovakia | SK | ✔ | 24 | SK31 1200 0000 1987 4263 7541 |
Slovenia | SI | ✔ | 19 | SI56 2633 0001 2039 086 |
Spain | ES | ✔ | 24 | ES91 2100 0418 4502 0005 1332 |
Sweden | SE | ✔ | 24 | SE45 5000 0000 0583 9825 7466 |
Switzerland | CH | ✔ | 21 | CH93 0076 2011 6238 5295 7 |
Timor-Leste | TL | 23 | TL38 0080 0123 4567 8910 157 | |
Tunisia | TN | 24 | TN59 1000 6035 1835 9847 8831 | |
Turkey | TR | 26 | TR33 0006 1005 1978 6457 8413 26 | |
Ukraine | UA | 29 | UA21 3223 1300 0002 6007 2335 6600 1 | |
United Arab Emirates | AE | 23 | AE07 0331 2345 6789 0123 456 | |
United Kingdom | GB | ✔ | 22 | GB29 NWBK 6016 1331 9268 19 |
Vatican City State | VA | 22 | VA59 001 1230 0001 2345 678 | |
Virgin Islands | VG | 24 | VG96 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.