Class IbanValidator
- All Implemented Interfaces:
IValidator
,Serializable
It validates to false when the value is no IBAN using the following algorithm:
The basis of the IBAN validation is to convert the IBAN into a number and to perform a basic Mod-97 calculation (as described in ISO 7064) on it. If the IBAN is valid, then the remainder equals 1. Rule process of IBAN validation is:
- Check that the total IBAN length is correct as per the country (see table below). If not, the IBAN is invalid.
- Check that the IBAN number/letter pattern is correct as per the country (see table below). If not, the IBAN is invalid.
- Move the four initial characters to the end of the string.
- Replace each letter in the string with two digits, thereby expanding the string, where A=10, B=11, ..., Z=35.
- Interpret the string as a decimal integer and compute the remainder of that number on division by 97.
- If the remainder is 1, the checks digits test is passed and the IBAN might be valid.
Example (fictitious United Kingdom bank, sort code 12-34-56, account 98765432):
IBAN: GB82 WEST 1234 5698 7654 32 Rearrange: W E S T12345698765432 G B82 Modulus: 3214282912345698765432161182 mod 97 = 1
Country | Code | Length | Pattern * |
Andorra | AD | 24 | U02D02D08A12 |
United Arab Emirates (The) | AE | 23 | U02D02D19 |
Albania | AL | 28 | U02D02D08A16 |
Austria | AT | 20 | U02D02D16 |
Azerbaijan | AZ | 28 | U02D02U04A20 |
Bosnia and Herzegovina | BA | 20 | U02D02D16 |
Belgium | BE | 16 | U02D02D12 |
Bulgaria | BG | 22 | U02D02U04D06A08 |
Bahrain | BH | 22 | U02D02U04A14 |
Brazil | BR | 29 | U02D02D23U01A01 |
Republic of Belarus | BY | 28 | U02D02A04D04A16 |
Switzerland | CH | 21 | U02D02D05A12 |
Costa Rica | CR | 22 | U02D02D18 |
Cyprus | CY | 28 | U02D02D08A16 |
Czech Republic | CZ | 24 | U02D02D20 |
Germany | DE | 22 | U02D02D18 |
Denmark | DK | 18 | U02D02D14 |
Dominican Republic | DO | 28 | U02D02A04D20 |
Estonia | EE | 20 | U02D02D16 |
Egypt | EG | 29 | U02D02D25 |
Spain | ES | 24 | U02D02D20 |
Finland | FI | 18 | U02D02D14 |
Faroe Islands | FO | 18 | U02D02D14 |
France | FR | 27 | U02D02D10A11D02 |
United Kingdom | GB | 22 | U02D02U04D14 |
Georgia | GE | 22 | U02D02U02D16 |
Gibraltar | GI | 23 | U02D02U04A15 |
Greenland | GL | 18 | U02D02D14 |
Greece | GR | 27 | U02D02D07A16 |
Guatemala | GT | 28 | U02D02A24 |
Croatia | HR | 21 | U02D02D17 |
Hungary | HU | 28 | U02D02D24 |
Ireland | IE | 22 | U02D02U04D14 |
Israel | IL | 23 | U02D02D19 |
Iraq | IQ | 23 | U02D02U04D15 |
Iceland | IS | 26 | U02D02D22 |
Italy | IT | 27 | U02D02U01D10A12 |
Jordan | JO | 30 | U02D02U04D04A18 |
Kuwait | KW | 30 | U02D02U04A22 |
Kazakhstan | KZ | 20 | U02D02D03A13 |
Lebanon | LB | 28 | U02D02D04A20 |
Saint Lucia | LC | 32 | U02D02U04A24 |
Liechtenstein | LI | 21 | U02D02D05A12 |
Lithuania | LT | 20 | U02D02D16 |
Luxembourg | LU | 20 | U02D02D03A13 |
Latvia | LV | 21 | U02D02U04A13 |
Libya | LY | 25 | U02D02D21 |
Monaco | MC | 27 | U02D02D10A11D02 |
Moldova | MD | 24 | U02D02A20 |
Montenegro | ME | 22 | U02D02D18 |
Macedonia | MK | 19 | U02D02D03A10D02 |
Mauritania | MR | 27 | U02D02D23 |
Malta | MT | 31 | U02D02U04D05A18 |
Mauritius | MU | 30 | U02D02U04D19U03 |
Netherlands (The) | NL | 18 | U02D02U04D10 |
Norway | NO | 15 | U02D02D11 |
Pakistan | PK | 24 | U02D02U04A16 |
Poland | PL | 28 | U02D02D24 |
Palestine, State of | PS | 29 | U02D02U04A21 |
Portugal | PT | 25 | U02D02D21 |
Qatar | QA | 29 | U02D02U04A21 |
Romania | RO | 24 | U02D02U04A16 |
Serbia | RS | 22 | U02D02D18 |
Saudi Arabia | SA | 24 | U02D02D02A18 |
Seychelles | SC | 31 | U02D02U04D20U03 |
Sweden | SE | 24 | U02D02D20 |
Slovenia | SI | 19 | U02D02D15 |
Slovakia | SK | 24 | U02D02D20 |
San Marino | SM | 27 | U02D02U01D10A12 |
Sao Tome and Principe | ST | 25 | U02D02D21 |
El Salvador | SV | 28 | U02D02U04D20 |
Timor-Lesteno | TL | 23 | U02D02D19 |
Tunisia | TN | 24 | U02D02D20 |
Turkey | TR | 26 | U02D02D06A16 |
Ukraine | UA | 29 | U02D02D06A19 |
Vatican City State | VA | 22 | U02D02D18 |
Virgin Islands | VG | 24 | U02D02U04D16 |
Kosovo | XK | 20 | U02D02D16 |
* where U is upper case alpha characters (A-Z), D is numeric characters (0-9) and A mixed case alphanumeric characters (a-z, A-Z, 0-9) followed by a number indicating the quantifier
Note that: This validator may return true for invalid bank account numbers, since it only uses the basic Mod-97 calculation check and some simple pattern checks. No country/bank specific bank account restriction checks are performed.
- Since:
- 9.0
- Author:
- Jon van Leuven
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
validate
(IValue attrValue, IParameters parameters) This method will be invoked for each value that should be validated by this validator.Methods inherited from class com.aquima.interactions.framework.validator.ValidatorBase
getTypeName
-
Constructor Details
-
IbanValidator
Constructs the validator using a data-source.- Parameters:
name
- The name of the validator type.
-
-
Method Details
-
validate
Description copied from interface:IValidator
This method will be invoked for each value that should be validated by this validator.- Parameters:
attrValue
- The value that should be validated.parameters
- The (optional) parameters that can be used during validation.- Returns:
- Boolean indicating if the value is deemed valid by this validator.
-