Fix IBAN validator
This commit is contained in:
parent
d4a78fec32
commit
3eeb3067e3
@ -31,7 +31,7 @@ class IbanValidator extends ConstraintValidator
|
|||||||
}
|
}
|
||||||
|
|
||||||
// An IBAN without a country code is not an IBAN.
|
// 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));
|
$this->context->addViolation($constraint->message, array('{{ value }}' => $value));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -50,7 +50,7 @@ class IbanValidator extends ConstraintValidator
|
|||||||
.strval(ord($teststring{1}) - 55)
|
.strval(ord($teststring{1}) - 55)
|
||||||
.substr($teststring, 2, 2);
|
.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);
|
return intval(ord(strtolower($letter[0])) - 87);
|
||||||
}, $teststring);
|
}, $teststring);
|
||||||
|
|
||||||
|
@ -182,6 +182,10 @@ class IbanValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('foo'),
|
array('foo'),
|
||||||
array('123'),
|
array('123'),
|
||||||
array('0750447346'),
|
array('0750447346'),
|
||||||
|
|
||||||
|
//Ibans with lower case values are invalid
|
||||||
|
array('Ae260211000000230064016'),
|
||||||
|
array('ae260211000000230064016')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user