From 0d824a72fa8300764f1cd49aaf943941392ae096 Mon Sep 17 00:00:00 2001 From: MatTheCat Date: Sat, 9 Mar 2024 17:19:41 +0100 Subject: [PATCH] =?UTF-8?q?[Validator]=20Allow=20BICs=E2=80=99=20first=20f?= =?UTF-8?q?our=20characters=20to=20be=20digits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Component/Validator/Constraints/BicValidator.php | 10 ---------- .../Validator/Tests/Constraints/BicValidatorTest.php | 7 +------ 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/BicValidator.php b/src/Symfony/Component/Validator/Constraints/BicValidator.php index 5e9d76621ae3e..240f2dd26c41a 100644 --- a/src/Symfony/Component/Validator/Constraints/BicValidator.php +++ b/src/Symfony/Component/Validator/Constraints/BicValidator.php @@ -102,16 +102,6 @@ public function validate($value, Constraint $constraint) return; } - // first 4 letters must be alphabetic (bank code) - if (!ctype_alpha(substr($canonicalize, 0, 4))) { - $this->context->buildViolation($constraint->message) - ->setParameter('{{ value }}', $this->formatValue($value)) - ->setCode(Bic::INVALID_BANK_CODE_ERROR) - ->addViolation(); - - return; - } - $bicCountryCode = substr($canonicalize, 4, 2); if (!isset(self::BIC_COUNTRY_TO_IBAN_COUNTRY_MAP[$bicCountryCode]) && !Countries::exists($bicCountryCode)) { $this->context->buildViolation($constraint->message) diff --git a/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php index 0acfb67a63bd0..536e74b073a74 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php @@ -199,7 +199,6 @@ public function testValidBics($bic) public static function getValidBics() { - // http://formvalidation.io/validators/bic/ return [ ['ASPKAT2LXXX'], ['ASPKAT2L'], @@ -207,6 +206,7 @@ public static function getValidBics() ['UNCRIT2B912'], ['DABADKKK'], ['RZOOAT2L303'], + ['1SBACNBXSHA'], ]; } @@ -252,11 +252,6 @@ public static function getInvalidBics() ['ASPKAT2LX', Bic::INVALID_LENGTH_ERROR], ['ASPKAT2LXXX1', Bic::INVALID_LENGTH_ERROR], ['DABADKK', Bic::INVALID_LENGTH_ERROR], - ['1SBACNBXSHA', Bic::INVALID_BANK_CODE_ERROR], - ['RZ00AT2L303', Bic::INVALID_BANK_CODE_ERROR], - ['D2BACNBXSHA', Bic::INVALID_BANK_CODE_ERROR], - ['DS3ACNBXSHA', Bic::INVALID_BANK_CODE_ERROR], - ['DSB4CNBXSHA', Bic::INVALID_BANK_CODE_ERROR], ['DEUT12HH', Bic::INVALID_COUNTRY_CODE_ERROR], ['DSBAC6BXSHA', Bic::INVALID_COUNTRY_CODE_ERROR], ['DSBA5NBXSHA', Bic::INVALID_COUNTRY_CODE_ERROR],