diff --git a/src/Symfony/Component/Validator/Constraints/IbanValidator.php b/src/Symfony/Component/Validator/Constraints/IbanValidator.php index 1afc8f01b7..3ec4c6ea7a 100644 --- a/src/Symfony/Component/Validator/Constraints/IbanValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IbanValidator.php @@ -30,6 +30,13 @@ class IbanValidator extends ConstraintValidator return; } + // An IBAN without a country code is not an IBAN. + if (0 === preg_match('/[A-Za-z]/', $value)) { + $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + + return; + } + $teststring = preg_replace('/\s+/', '', $value); if (strlen($teststring) < 4) { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php index cfd9f2cd8f..eae04e352f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php @@ -182,6 +182,7 @@ class IbanValidatorTest extends \PHPUnit_Framework_TestCase array('CY170020 128 0000 0012 0052 7600'), array('foo'), array('123'), + array('0750447346') ); } }