Skip to content

Commit 855b714

Browse files
committed
IBAN Check digits should always between 2 and 98
A ECBS document (https://www.ecbs.org/Download/EBS204_V3.PDF) replicates part of the ISO/IEC 7064:2003 standard as a method for generating check digits in the range 02 to 98. Example of invalid IBANs, which before were valid, are NL01INGB0001393698 and NL01RABO0331811235. You can check them at iban.com to verify they are indeed invalid.
1 parent 84f0b88 commit 855b714

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Symfony/Component/Validator/Constraints/IbanValidator.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,18 @@ public function validate($value, Constraint $constraint)
228228
return;
229229
}
230230

231+
// Check digits should always between 2 and 98
232+
// A ECBS document (https://www.ecbs.org/Download/EBS204_V3.PDF) replicates part of the ISO/IEC 7064:2003 standard as a method for generating check digits in the range 02 to 98.
233+
$checkDigits = (int) substr($canonicalized, 2, 4);
234+
if ($checkDigits < 2 || $checkDigits > 98) {
235+
$this->context->buildViolation($constraint->message)
236+
->setParameter('{{ value }}', $this->formatValue($value))
237+
->setCode(Iban::CHECKSUM_FAILED_ERROR)
238+
->addViolation();
239+
240+
return;
241+
}
242+
231243
// Move the first four characters to the end
232244
// e.g. CH93 0076 2011 6238 5295 7
233245
// -> 0076 2011 6238 5295 7 CH93

src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,12 @@ public static function getIbansWithValidFormatButIncorrectChecksum()
401401
['UA213223130000026007233566002'], // Ukraine
402402
['AE260211000000230064017'], // United Arab Emirates
403403
['VA59001123000012345671'], // Vatican City State
404+
405+
// Checksum digits not between 02 and 98
406+
['FO00 5432 0388 8999 44'], // Faroe Islands
407+
['NL01INGB0001393698'], // Netherlands
408+
['NL01RABO0331811235'], // Netherlands
409+
['RU99 0445 2560 0407 0281 0412 3456 7890 1'], // Russia
404410
];
405411
}
406412

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy