From 436dcba003ce6c06d8ac839d682a689da368b119 Mon Sep 17 00:00:00 2001 From: Maximilian Beckers Date: Thu, 16 Mar 2023 08:57:07 +0100 Subject: [PATCH] [Validator] Update BIC validator IBAN mappings --- .../Validator/Constraints/BicValidator.php | 17 +++++++++++++---- .../Tests/Constraints/BicValidatorTest.php | 9 +++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/BicValidator.php b/src/Symfony/Component/Validator/Constraints/BicValidator.php index 37e922de7f92f..6c038067b7940 100644 --- a/src/Symfony/Component/Validator/Constraints/BicValidator.php +++ b/src/Symfony/Component/Validator/Constraints/BicValidator.php @@ -29,8 +29,9 @@ */ class BicValidator extends ConstraintValidator { + // Reference: https://www.iban.com/structure private const BIC_COUNTRY_TO_IBAN_COUNTRY_MAP = [ - // Reference: https://www.ecbs.org/iban/france-bank-account-number.html + // FR includes: 'GF' => 'FR', // French Guiana 'PF' => 'FR', // French Polynesia 'TF' => 'FR', // French Southern Territories @@ -39,13 +40,20 @@ class BicValidator extends ConstraintValidator 'YT' => 'FR', // Mayotte 'NC' => 'FR', // New Caledonia 'RE' => 'FR', // Reunion + 'BL' => 'FR', // Saint Barthelemy + 'MF' => 'FR', // Saint Martin (French part) 'PM' => 'FR', // Saint Pierre and Miquelon 'WF' => 'FR', // Wallis and Futuna Islands - // Reference: https://www.ecbs.org/iban/united-kingdom-uk-bank-account-number.html + // GB includes: 'JE' => 'GB', // Jersey 'IM' => 'GB', // Isle of Man 'GG' => 'GB', // Guernsey 'VG' => 'GB', // British Virgin Islands + // FI includes: + 'AX' => 'FI', // Aland Islands + // ES includes: + 'IC' => 'ES', // Canary Islands + 'EA' => 'ES', // Ceuta and Melilla ]; private $propertyAccessor; @@ -104,7 +112,8 @@ public function validate($value, Constraint $constraint) return; } - if (!Countries::exists(substr($canonicalize, 4, 2))) { + $bicCountryCode = substr($canonicalize, 4, 2); + if (!isset(self::BIC_COUNTRY_TO_IBAN_COUNTRY_MAP[$bicCountryCode]) && !Countries::exists($bicCountryCode)) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) ->setCode(Bic::INVALID_COUNTRY_CODE_ERROR) @@ -137,7 +146,7 @@ public function validate($value, Constraint $constraint) return; } $ibanCountryCode = substr($iban, 0, 2); - if (ctype_alpha($ibanCountryCode) && !$this->bicAndIbanCountriesMatch(substr($canonicalize, 4, 2), $ibanCountryCode)) { + if (ctype_alpha($ibanCountryCode) && !$this->bicAndIbanCountriesMatch($bicCountryCode, $ibanCountryCode)) { $this->context->buildViolation($constraint->ibanMessage) ->setParameter('{{ value }}', $this->formatValue($value)) ->setParameter('{{ iban }}', $iban) diff --git a/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php index 564fa30c95957..0acfb67a63bd0 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php @@ -299,6 +299,8 @@ public static function getValidBicSpecialCases() yield ['BNPAYTGX', 'FR14 2004 1010 0505 0001 3M02 606']; yield ['BNPANCGX', 'FR14 2004 1010 0505 0001 3M02 606']; yield ['BNPAREGX', 'FR14 2004 1010 0505 0001 3M02 606']; + yield ['BNPABLGX', 'FR14 2004 1010 0505 0001 3M02 606']; + yield ['BNPAMFGX', 'FR14 2004 1010 0505 0001 3M02 606']; yield ['BNPAPMGX', 'FR14 2004 1010 0505 0001 3M02 606']; yield ['BNPAWFGX', 'FR14 2004 1010 0505 0001 3M02 606']; @@ -307,6 +309,13 @@ public static function getValidBicSpecialCases() yield ['BARCIMSA', 'GB12 CPBK 0892 9965 0449 911']; yield ['BARCGGSA', 'GB12 CPBK 0892 9965 0449 911']; yield ['BARCVGSA', 'GB12 CPBK 0892 9965 0449 911']; + + // FI related special cases + yield ['NDEAAXHH', 'FI14 1009 3000 1234 58']; + + // ES related special cases + yield ['CAIXICBBXXX', 'ES79 2100 0813 6101 2345 6789']; + yield ['CAIXEABBXXX', 'ES79 2100 0813 6101 2345 6789']; } } 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