Skip to content

Commit

Permalink
Fix IBAN validator
Browse files Browse the repository at this point in the history
  • Loading branch information
sprain committed Mar 19, 2014
1 parent d4a78fe commit 3eeb306
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/Validator/Constraints/IbanValidator.php
Expand Up @@ -31,7 +31,7 @@ public function validate($value, Constraint $constraint)
}

// An IBAN without a country code is not an IBAN.
if (0 === preg_match('/[A-Za-z]/', $value)) {
if (0 === preg_match('/[A-Z]/', $value)) {
$this->context->addViolation($constraint->message, array('{{ value }}' => $value));

return;
Expand All @@ -50,7 +50,7 @@ public function validate($value, Constraint $constraint)
.strval(ord($teststring{1}) - 55)
.substr($teststring, 2, 2);

$teststring = preg_replace_callback('/[A-Za-z]/', function ($letter) {
$teststring = preg_replace_callback('/[A-Z]/', function ($letter) {
return intval(ord(strtolower($letter[0])) - 87);
}, $teststring);

Expand Down
Expand Up @@ -182,6 +182,10 @@ public function getInvalidIbans()
array('foo'),
array('123'),
array('0750447346'),

//Ibans with lower case values are invalid
array('Ae260211000000230064016'),
array('ae260211000000230064016')
);
}
}

0 comments on commit 3eeb306

Please sign in to comment.