iban validator

Validate an IBAN (International Bank Account Number)

Options

Using with form field
The HTML attributes are used to set the validator options via the Declarative plugin
NameHTML attributeTypeDescription
countrydata-fv-iban___countryStringAn ISO-3166 country code
messagedata-fv-iban___messageStringThe error message
sepadata-fv-iban___sepaBooleanSet it to true (false) to indicate that the IBAN number must be (not be) from SEPA countries. The list of SEPA countries are indicated in the table below. By default, this option is not defined
If the country is not defined, it will be parsed from the IBAN number. The validator supports the following countries (sorted by the country code in alphabetical order):
CountryCodeSepaSample IBAN
AlbaniaALNoAL47212110090000000235698741
AlgeriaDZNoDZ4000400174401001050486
AndorraADNoAD1200012030200359100100
AngolaAONoAO06000600000100037131174
AustriaATYesAT611904300234573201
AzerbaijanAZNoAZ21NABZ00000000137010001944
BahrainBHNoBH29BMAG1299123456BH00
Bosnia and HerzegovinaBANoBA391290079401028494
BelgiumBEYesBE68539007547034
BeninBJNoBJ11B00610100400271101192591
BrazilBRNoBR9700360305000010009795493P1
BulgariaBGYesBG80BNBG96611020345678
Burkina FasoBFNoBF1030134020015400945000643
BurundiBINoBI43201011067444
CameroonCMNoCM2110003001000500000605306
Cape VerdeCVNoCV64000300004547069110176
Costa RicaCRNoCR0515202001026284066
CroatiaHRYesHR1210010051863000160
CyprusCYYesCY17002001280000001200527600
Czech RepublicCZYesCZ6508000000192000145399
DenmarkDKYesDK5000400440116243
Dominican RepublicDONoDO28BAGR00000001212453611324
East TimorTLNoTL380080012345678910157
EstoniaEEYesEE382200221020145685
Faroe IslandsFONoFO1464600009692713
FinlandFIYesFI2112345600000785
FranceFRYesFR1420041010050500013M02606
GuatemalaGTNoGT82TRAJ01020000001210029690
GeorgiaGENoGE29NB0000000101904917
GermanyDEYesDE89370400440532013000
GibraltarGIYesGI75NWBK000000007099453
GreeceGRYesGR1601101250000000012300695
GreenlandGLNoGL8964710001000206
HungaryHUYesHU42117730161111101800000000
IcelandISYesIS140159260076545510730339
IranIRNoIR580540105180021273113007
IrelandIEYesIE29AIBK93115212345678
IsraelILNoIL620108000000099999999
ItalyITYesIT60X0542811101000000123456
Ivory CoastCINoCI05A00060174100178530011852
JordanJONoJO94CBJO0010000000000131000302
KazakhstanKZNoKZ176010251000042993
KuwaitKWNoKW74NBOK0000000000001000372151
LatviaLVYesLV80BANK0000435195001
LebanonLBNoLB30099900000001001925579115
LiechtensteinLIYesLI21088100002324013AA
LithuaniaLTYesLT121000011101001000
LuxembourgLUYesLU280019400644750000
MacedoniaMKNoMK07300000000042425
MadagascarMGNoMG4600005030010101914016056
MaltaMTYesMT84MALT011000012345MTLCAST001S
MauritaniaMRNoMR1300012000010000002037372
MauritiusMUNoMU17BOMM0101101030300200000MUR
MaliMLNoML03D00890170001002120000447
MoldovaMDNoMD24AG000225100013104168
MonacoMCYesMC5813488000010051108001292
MontenegroMENoME25505000012345678951
MozambiqueMZNoMZ59000100000011834194157
NetherlandsNLYesNL91ABNA0417164300
NorwayNOYesNO9386011117947
PakistanPKNoPK24SCBL0000001171495101
PalestinePSNoPS92PALS000000000400123456702
PolandPLYesPL27114020040000300201355387
PortugalPTYesPT50000201231234567890154
QatarQANoQA58DOHB00001234567890ABCDEFG
Republic of KosovoXKNoXK051212012345678906
RomaniaROYesRO49AAAA1B31007593840000
San MarinoSMYesSM86U0322509800000000270100
Saudi ArabiaSANoSA0380000000608010167519
SenegalSNNoSN12K00100152000025690007542
SerbiaRSNoRS35260005601001611379
SlovakiaSKYesSK3112000000198742637541
SloveniaSIYesSI56191000000123438
SpainESYesES9121000418450200051332
SwedenSEYesSE3550000000054910000003
SwitzerlandCHYesCH9300762011623852957
TunisiaTNNoTN5914207207100707129648
TurkeyTRNoTR330006100519786457841326
United Arab EmiratesAENoAE260211000000230064016
United KingdomGBYesGB29NWBK60161331926819
Virgin Islands, BritishVGNoVG96VPVG0000012345678901
Using the ES6 module
// You might need to change the importing path
import { iban } from '/vendors/@form-validation/cjs/validator-iban';
const result = iban().validate({
value: ...,
options: {
country: ...,
message: ...,
sepa: ...,
},
});
/*
result is an object of
{
valid: true or false,
message: The error message
}
*/
Using the npm package
  • Install the validator package:
$ npm install @form-validation/validator-iban
  • Use the iban validator:
import { iban } from '@form-validation/validator-iban';
const result = iban().validate({
value: ...,
options: {
country: ...,
message: ...,
sepa: ...,
},
});

Basic example

iban validator

NPM package example

The following snippet shows how to use the iban validator with the npm package:
import { iban } from '@form-validation/validator-iban';
const res1 = iban().validate({
value: 'AT611904300234573201',
options: {
message: 'The value is not a valid IBAN',
},
});
// res1.valid === true
const res2 = iban().validate({
value: 'GB29NWBK6016133192681',
options: {
message: 'The value is not a valid IBAN',
},
});
// res2.valid === false

See also

Changelog

v2.1.0
  • The validator doesn't work properly if the message property isn't defined
v2.0.0
  • Add the npm package
v1.6.0
  • Fixed an issue that the country option isn't passed to the placeholder message
v1.4.0
  • Support the new format of Costa Rica IBAN number (22 digits currently)