Documentation

IbanValidator extends ConstraintValidator
in package

Base class for constraint validators.

Tags
author

Manuel Reinhard manu@sprain.ch

author

Michael Schummel

author

Bernhard Schussek bschussek@gmail.com

see
http://www.michael-schummel.de/2007/10/05/iban-prufung-mit-php/

Table of Contents

Constants

OBJECT_TO_STRING  = 2
Whether to cast objects with a "__toString()" method to strings.
PRETTY_DATE  = 1
Whether to format {@link \DateTime} objects, either with the {@link \IntlDateFormatter} (if it is available) or as RFC-3339 dates ("Y-m-d H:i:s").
FORMATS  = [ 'AD' => 'AD\\d{2}\\d{4}\\d{4}[\\dA-Z]{12}', // Andorra 'AE' => 'AE\\d{2}\\d{3}\\d{16}', // United Arab Emirates 'AL' => 'AL\\d{2}\\d{8}[\\dA-Z]{16}', // Albania 'AO' => 'AO\\d{2}\\d{21}', // Angola 'AT' => 'AT\\d{2}\\d{5}\\d{11}', // Austria 'AX' => 'FI\\d{2}\\d{6}\\d{7}\\d{1}', // Aland Islands 'AZ' => 'AZ\\d{2}[A-Z]{4}[\\dA-Z]{20}', // Azerbaijan 'BA' => 'BA\\d{2}\\d{3}\\d{3}\\d{8}\\d{2}', // Bosnia and Herzegovina 'BE' => 'BE\\d{2}\\d{3}\\d{7}\\d{2}', // Belgium 'BF' => 'BF\\d{2}\\d{23}', // Burkina Faso 'BG' => 'BG\\d{2}[A-Z]{4}\\d{4}\\d{2}[\\dA-Z]{8}', // Bulgaria 'BH' => 'BH\\d{2}[A-Z]{4}[\\dA-Z]{14}', // Bahrain 'BI' => 'BI\\d{2}\\d{12}', // Burundi 'BJ' => 'BJ\\d{2}[A-Z]{1}\\d{23}', // Benin 'BY' => 'BY\\d{2}[\\dA-Z]{4}\\d{4}[\\dA-Z]{16}', // Belarus - https://bank.codes/iban/structure/belarus/ 'BL' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // Saint Barthelemy 'BR' => 'BR\\d{2}\\d{8}\\d{5}\\d{10}[A-Z][\\dA-Z]', // Brazil 'CG' => 'CG\\d{2}\\d{23}', // Congo 'CH' => 'CH\\d{2}\\d{5}[\\dA-Z]{12}', // Switzerland 'CI' => 'CI\\d{2}[A-Z]{1}\\d{23}', // Ivory Coast 'CM' => 'CM\\d{2}\\d{23}', // Cameron 'CR' => 'CR\\d{2}0\\d{3}\\d{14}', // Costa Rica 'CV' => 'CV\\d{2}\\d{21}', // Cape Verde 'CY' => 'CY\\d{2}\\d{3}\\d{5}[\\dA-Z]{16}', // Cyprus 'CZ' => 'CZ\\d{2}\\d{20}', // Czech Republic 'DE' => 'DE\\d{2}\\d{8}\\d{10}', // Germany 'DO' => 'DO\\d{2}[\\dA-Z]{4}\\d{20}', // Dominican Republic 'DK' => 'DK\\d{2}\\d{4}\\d{10}', // Denmark 'DZ' => 'DZ\\d{2}\\d{20}', // Algeria 'EE' => 'EE\\d{2}\\d{2}\\d{2}\\d{11}\\d{1}', // Estonia 'ES' => 'ES\\d{2}\\d{4}\\d{4}\\d{1}\\d{1}\\d{10}', // Spain (also includes Canary Islands, Ceuta and Melilla) 'FI' => 'FI\\d{2}\\d{6}\\d{7}\\d{1}', // Finland 'FO' => 'FO\\d{2}\\d{4}\\d{9}\\d{1}', // Faroe Islands 'FR' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // France 'GF' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // French Guyana 'GB' => 'GB\\d{2}[A-Z]{4}\\d{6}\\d{8}', // United Kingdom of Great Britain and Northern Ireland 'GE' => 'GE\\d{2}[A-Z]{2}\\d{16}', // Georgia 'GI' => 'GI\\d{2}[A-Z]{4}[\\dA-Z]{15}', // Gibraltar 'GL' => 'GL\\d{2}\\d{4}\\d{9}\\d{1}', // Greenland 'GP' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // Guadeloupe 'GR' => 'GR\\d{2}\\d{3}\\d{4}[\\dA-Z]{16}', // Greece 'GT' => 'GT\\d{2}[\\dA-Z]{4}[\\dA-Z]{20}', // Guatemala 'HR' => 'HR\\d{2}\\d{7}\\d{10}', // Croatia 'HU' => 'HU\\d{2}\\d{3}\\d{4}\\d{1}\\d{15}\\d{1}', // Hungary 'IE' => 'IE\\d{2}[A-Z]{4}\\d{6}\\d{8}', // Ireland 'IL' => 'IL\\d{2}\\d{3}\\d{3}\\d{13}', // Israel 'IR' => 'IR\\d{2}\\d{22}', // Iran 'IS' => 'IS\\d{2}\\d{4}\\d{2}\\d{6}\\d{10}', // Iceland 'IT' => 'IT\\d{2}[A-Z]{1}\\d{5}\\d{5}[\\dA-Z]{12}', // Italy 'JO' => 'JO\\d{2}[A-Z]{4}\\d{4}[\\dA-Z]{18}', // Jordan 'KW' => 'KW\\d{2}[A-Z]{4}\\d{22}', // KUWAIT 'KZ' => 'KZ\\d{2}\\d{3}[\\dA-Z]{13}', // Kazakhstan 'LB' => 'LB\\d{2}\\d{4}[\\dA-Z]{20}', // LEBANON 'LI' => 'LI\\d{2}\\d{5}[\\dA-Z]{12}', // Liechtenstein (Principality of) 'LT' => 'LT\\d{2}\\d{5}\\d{11}', // Lithuania 'LU' => 'LU\\d{2}\\d{3}[\\dA-Z]{13}', // Luxembourg 'LV' => 'LV\\d{2}[A-Z]{4}[\\dA-Z]{13}', // Latvia 'MC' => 'MC\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // Monaco 'MD' => 'MD\\d{2}[\\dA-Z]{2}[\\dA-Z]{18}', // Moldova 'ME' => 'ME\\d{2}\\d{3}\\d{13}\\d{2}', // Montenegro 'MF' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // Saint Martin (French part) 'MG' => 'MG\\d{2}\\d{23}', // Madagascar 'MK' => 'MK\\d{2}\\d{3}[\\dA-Z]{10}\\d{2}', // Macedonia, Former Yugoslav Republic of 'ML' => 'ML\\d{2}[A-Z]{1}\\d{23}', // Mali 'MQ' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // Martinique 'MR' => 'MR\\d{2}\\d{5}\\d{5}\\d{11}\\d{2}', // Mauritania 'MT' => 'MT\\d{2}[A-Z]{4}\\d{5}[\\dA-Z]{18}', // Malta 'MU' => 'MU\\d{2}[A-Z]{4}\\d{2}\\d{2}\\d{12}\\d{3}[A-Z]{3}', // Mauritius 'MZ' => 'MZ\\d{2}\\d{21}', // Mozambique 'NC' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // New Caledonia 'NL' => 'NL\\d{2}[A-Z]{4}\\d{10}', // The Netherlands 'NO' => 'NO\\d{2}\\d{4}\\d{6}\\d{1}', // Norway 'PF' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // French Polynesia 'PK' => 'PK\\d{2}[A-Z]{4}[\\dA-Z]{16}', // Pakistan 'PL' => 'PL\\d{2}\\d{8}\\d{16}', // Poland 'PM' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // Saint Pierre et Miquelon 'PS' => 'PS\\d{2}[A-Z]{4}[\\dA-Z]{21}', // Palestine, State of 'PT' => 'PT\\d{2}\\d{4}\\d{4}\\d{11}\\d{2}', // Portugal (plus Azores and Madeira) 'QA' => 'QA\\d{2}[A-Z]{4}[\\dA-Z]{21}', // Qatar 'RE' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // Reunion 'RO' => 'RO\\d{2}[A-Z]{4}[\\dA-Z]{16}', // Romania 'RS' => 'RS\\d{2}\\d{3}\\d{13}\\d{2}', // Serbia 'SA' => 'SA\\d{2}\\d{2}[\\dA-Z]{18}', // Saudi Arabia 'SE' => 'SE\\d{2}\\d{3}\\d{16}\\d{1}', // Sweden 'SI' => 'SI\\d{2}\\d{5}\\d{8}\\d{2}', // Slovenia 'SK' => 'SK\\d{2}\\d{4}\\d{6}\\d{10}', // Slovak Republic 'SM' => 'SM\\d{2}[A-Z]{1}\\d{5}\\d{5}[\\dA-Z]{12}', // San Marino 'SN' => 'SN\\d{2}[A-Z]{1}\\d{23}', // Senegal 'TF' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // French Southern Territories 'TL' => 'TL\\d{2}\\d{3}\\d{14}\\d{2}', // Timor-Leste 'TN' => 'TN\\d{2}\\d{2}\\d{3}\\d{13}\\d{2}', // Tunisia 'TR' => 'TR\\d{2}\\d{5}[\\dA-Z]{1}[\\dA-Z]{16}', // Turkey 'UA' => 'UA\\d{2}\\d{6}[\\dA-Z]{19}', // Ukraine 'VA' => 'VA\\d{2}\\d{3}\\d{15}', // Vatican City State 'VG' => 'VG\\d{2}[A-Z]{4}\\d{16}', // Virgin Islands, British 'WF' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // Wallis and Futuna Islands 'XK' => 'XK\\d{2}\\d{4}\\d{10}\\d{2}', // Republic of Kosovo 'YT' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', ]
IBAN country specific formats.

Properties

$context  : ExecutionContextInterface

Methods

initialize()  : mixed
Initializes the constraint validator.
validate()  : mixed
{@inheritdoc}
formatTypeOf()  : string
Returns a string representation of the type of the value.
formatValue()  : string
Returns a string representation of the value.
formatValues()  : string
Returns a string representation of a list of values.
bigModulo97()  : int
toBigInt()  : string

Constants

OBJECT_TO_STRING

Whether to cast objects with a "__toString()" method to strings.

public mixed OBJECT_TO_STRING = 2

PRETTY_DATE

Whether to format {@link \DateTime} objects, either with the {@link \IntlDateFormatter} (if it is available) or as RFC-3339 dates ("Y-m-d H:i:s").

public mixed PRETTY_DATE = 1

FORMATS

IBAN country specific formats.

private mixed FORMATS = [ 'AD' => 'AD\\d{2}\\d{4}\\d{4}[\\dA-Z]{12}', // Andorra 'AE' => 'AE\\d{2}\\d{3}\\d{16}', // United Arab Emirates 'AL' => 'AL\\d{2}\\d{8}[\\dA-Z]{16}', // Albania 'AO' => 'AO\\d{2}\\d{21}', // Angola 'AT' => 'AT\\d{2}\\d{5}\\d{11}', // Austria 'AX' => 'FI\\d{2}\\d{6}\\d{7}\\d{1}', // Aland Islands 'AZ' => 'AZ\\d{2}[A-Z]{4}[\\dA-Z]{20}', // Azerbaijan 'BA' => 'BA\\d{2}\\d{3}\\d{3}\\d{8}\\d{2}', // Bosnia and Herzegovina 'BE' => 'BE\\d{2}\\d{3}\\d{7}\\d{2}', // Belgium 'BF' => 'BF\\d{2}\\d{23}', // Burkina Faso 'BG' => 'BG\\d{2}[A-Z]{4}\\d{4}\\d{2}[\\dA-Z]{8}', // Bulgaria 'BH' => 'BH\\d{2}[A-Z]{4}[\\dA-Z]{14}', // Bahrain 'BI' => 'BI\\d{2}\\d{12}', // Burundi 'BJ' => 'BJ\\d{2}[A-Z]{1}\\d{23}', // Benin 'BY' => 'BY\\d{2}[\\dA-Z]{4}\\d{4}[\\dA-Z]{16}', // Belarus - https://bank.codes/iban/structure/belarus/ 'BL' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // Saint Barthelemy 'BR' => 'BR\\d{2}\\d{8}\\d{5}\\d{10}[A-Z][\\dA-Z]', // Brazil 'CG' => 'CG\\d{2}\\d{23}', // Congo 'CH' => 'CH\\d{2}\\d{5}[\\dA-Z]{12}', // Switzerland 'CI' => 'CI\\d{2}[A-Z]{1}\\d{23}', // Ivory Coast 'CM' => 'CM\\d{2}\\d{23}', // Cameron 'CR' => 'CR\\d{2}0\\d{3}\\d{14}', // Costa Rica 'CV' => 'CV\\d{2}\\d{21}', // Cape Verde 'CY' => 'CY\\d{2}\\d{3}\\d{5}[\\dA-Z]{16}', // Cyprus 'CZ' => 'CZ\\d{2}\\d{20}', // Czech Republic 'DE' => 'DE\\d{2}\\d{8}\\d{10}', // Germany 'DO' => 'DO\\d{2}[\\dA-Z]{4}\\d{20}', // Dominican Republic 'DK' => 'DK\\d{2}\\d{4}\\d{10}', // Denmark 'DZ' => 'DZ\\d{2}\\d{20}', // Algeria 'EE' => 'EE\\d{2}\\d{2}\\d{2}\\d{11}\\d{1}', // Estonia 'ES' => 'ES\\d{2}\\d{4}\\d{4}\\d{1}\\d{1}\\d{10}', // Spain (also includes Canary Islands, Ceuta and Melilla) 'FI' => 'FI\\d{2}\\d{6}\\d{7}\\d{1}', // Finland 'FO' => 'FO\\d{2}\\d{4}\\d{9}\\d{1}', // Faroe Islands 'FR' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // France 'GF' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // French Guyana 'GB' => 'GB\\d{2}[A-Z]{4}\\d{6}\\d{8}', // United Kingdom of Great Britain and Northern Ireland 'GE' => 'GE\\d{2}[A-Z]{2}\\d{16}', // Georgia 'GI' => 'GI\\d{2}[A-Z]{4}[\\dA-Z]{15}', // Gibraltar 'GL' => 'GL\\d{2}\\d{4}\\d{9}\\d{1}', // Greenland 'GP' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // Guadeloupe 'GR' => 'GR\\d{2}\\d{3}\\d{4}[\\dA-Z]{16}', // Greece 'GT' => 'GT\\d{2}[\\dA-Z]{4}[\\dA-Z]{20}', // Guatemala 'HR' => 'HR\\d{2}\\d{7}\\d{10}', // Croatia 'HU' => 'HU\\d{2}\\d{3}\\d{4}\\d{1}\\d{15}\\d{1}', // Hungary 'IE' => 'IE\\d{2}[A-Z]{4}\\d{6}\\d{8}', // Ireland 'IL' => 'IL\\d{2}\\d{3}\\d{3}\\d{13}', // Israel 'IR' => 'IR\\d{2}\\d{22}', // Iran 'IS' => 'IS\\d{2}\\d{4}\\d{2}\\d{6}\\d{10}', // Iceland 'IT' => 'IT\\d{2}[A-Z]{1}\\d{5}\\d{5}[\\dA-Z]{12}', // Italy 'JO' => 'JO\\d{2}[A-Z]{4}\\d{4}[\\dA-Z]{18}', // Jordan 'KW' => 'KW\\d{2}[A-Z]{4}\\d{22}', // KUWAIT 'KZ' => 'KZ\\d{2}\\d{3}[\\dA-Z]{13}', // Kazakhstan 'LB' => 'LB\\d{2}\\d{4}[\\dA-Z]{20}', // LEBANON 'LI' => 'LI\\d{2}\\d{5}[\\dA-Z]{12}', // Liechtenstein (Principality of) 'LT' => 'LT\\d{2}\\d{5}\\d{11}', // Lithuania 'LU' => 'LU\\d{2}\\d{3}[\\dA-Z]{13}', // Luxembourg 'LV' => 'LV\\d{2}[A-Z]{4}[\\dA-Z]{13}', // Latvia 'MC' => 'MC\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // Monaco 'MD' => 'MD\\d{2}[\\dA-Z]{2}[\\dA-Z]{18}', // Moldova 'ME' => 'ME\\d{2}\\d{3}\\d{13}\\d{2}', // Montenegro 'MF' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // Saint Martin (French part) 'MG' => 'MG\\d{2}\\d{23}', // Madagascar 'MK' => 'MK\\d{2}\\d{3}[\\dA-Z]{10}\\d{2}', // Macedonia, Former Yugoslav Republic of 'ML' => 'ML\\d{2}[A-Z]{1}\\d{23}', // Mali 'MQ' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // Martinique 'MR' => 'MR\\d{2}\\d{5}\\d{5}\\d{11}\\d{2}', // Mauritania 'MT' => 'MT\\d{2}[A-Z]{4}\\d{5}[\\dA-Z]{18}', // Malta 'MU' => 'MU\\d{2}[A-Z]{4}\\d{2}\\d{2}\\d{12}\\d{3}[A-Z]{3}', // Mauritius 'MZ' => 'MZ\\d{2}\\d{21}', // Mozambique 'NC' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // New Caledonia 'NL' => 'NL\\d{2}[A-Z]{4}\\d{10}', // The Netherlands 'NO' => 'NO\\d{2}\\d{4}\\d{6}\\d{1}', // Norway 'PF' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // French Polynesia 'PK' => 'PK\\d{2}[A-Z]{4}[\\dA-Z]{16}', // Pakistan 'PL' => 'PL\\d{2}\\d{8}\\d{16}', // Poland 'PM' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // Saint Pierre et Miquelon 'PS' => 'PS\\d{2}[A-Z]{4}[\\dA-Z]{21}', // Palestine, State of 'PT' => 'PT\\d{2}\\d{4}\\d{4}\\d{11}\\d{2}', // Portugal (plus Azores and Madeira) 'QA' => 'QA\\d{2}[A-Z]{4}[\\dA-Z]{21}', // Qatar 'RE' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // Reunion 'RO' => 'RO\\d{2}[A-Z]{4}[\\dA-Z]{16}', // Romania 'RS' => 'RS\\d{2}\\d{3}\\d{13}\\d{2}', // Serbia 'SA' => 'SA\\d{2}\\d{2}[\\dA-Z]{18}', // Saudi Arabia 'SE' => 'SE\\d{2}\\d{3}\\d{16}\\d{1}', // Sweden 'SI' => 'SI\\d{2}\\d{5}\\d{8}\\d{2}', // Slovenia 'SK' => 'SK\\d{2}\\d{4}\\d{6}\\d{10}', // Slovak Republic 'SM' => 'SM\\d{2}[A-Z]{1}\\d{5}\\d{5}[\\dA-Z]{12}', // San Marino 'SN' => 'SN\\d{2}[A-Z]{1}\\d{23}', // Senegal 'TF' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // French Southern Territories 'TL' => 'TL\\d{2}\\d{3}\\d{14}\\d{2}', // Timor-Leste 'TN' => 'TN\\d{2}\\d{2}\\d{3}\\d{13}\\d{2}', // Tunisia 'TR' => 'TR\\d{2}\\d{5}[\\dA-Z]{1}[\\dA-Z]{16}', // Turkey 'UA' => 'UA\\d{2}\\d{6}[\\dA-Z]{19}', // Ukraine 'VA' => 'VA\\d{2}\\d{3}\\d{15}', // Vatican City State 'VG' => 'VG\\d{2}[A-Z]{4}\\d{16}', // Virgin Islands, British 'WF' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', // Wallis and Futuna Islands 'XK' => 'XK\\d{2}\\d{4}\\d{10}\\d{2}', // Republic of Kosovo 'YT' => 'FR\\d{2}\\d{5}\\d{5}[\\dA-Z]{11}\\d{2}', ]

The first 2 characters from an IBAN format are the two-character ISO country code. The following 2 characters represent the check digits calculated from the rest of the IBAN characters. The rest are up to thirty alphanumeric characters for a BBAN (Basic Bank Account Number) which has a fixed length per country and, included within it, a bank identifier with a fixed position and a fixed length per country

Tags
see
https://www.swift.com/sites/default/files/resources/iban_registry.pdf

Properties

Methods

formatTypeOf()

Returns a string representation of the type of the value.

protected formatTypeOf(mixed $value) : string

This method should be used if you pass the type of a value as message parameter to a constraint violation. Note that such parameters should usually not be included in messages aimed at non-technical people.

Parameters
$value : mixed
Return values
string

formatValue()

Returns a string representation of the value.

protected formatValue(mixed $value[, int $format = 0 ]) : string

This method returns the equivalent PHP tokens for most scalar types (i.e. "false" for false, "1" for 1 etc.). Strings are always wrapped in double quotes ("). Objects, arrays and resources are formatted as "object", "array" and "resource". If the $format bitmask contains the PRETTY_DATE bit, then objects will be formatted with the . If it is not available, they will be formatted as RFC-3339 dates ("Y-m-d H:i:s").

Be careful when passing message parameters to a constraint violation that (may) contain objects, arrays or resources. These parameters should only be displayed for technical users. Non-technical users won't know what an "object", "array" or "resource" is and will be confused by the violation message.

Parameters
$value : mixed
$format : int = 0

A bitwise combination of the format constants in this class

Return values
string

formatValues()

Returns a string representation of a list of values.

protected formatValues(array<string|int, mixed> $values[, int $format = 0 ]) : string

Each of the values is converted to a string using . The values are then concatenated with commas.

Parameters
$values : array<string|int, mixed>

A list of values

$format : int = 0

A bitwise combination of the format constants in this class

Tags
see
formatValue()
Return values
string

bigModulo97()

private static bigModulo97(string $bigInt) : int
Parameters
$bigInt : string
Return values
int

toBigInt()

private static toBigInt(string $string) : string
Parameters
$string : string
Return values
string

        
On this page

Search results