Skip to content

Commit c63584f

Browse files
Merge branch '5.4' into 6.2
* 5.4: re-allow phpdocumentor/type-resolver 1.7 skip test using attributes on PHP 7 [HttpClient] Encode and decode curly brackets {} fix: GetSetMethodNormalizer::supportss should not check ignored methods Stop stopwatch events in case of exception add translations for the filename max length validator option [Validator] Update BIC validator IBAN mappings [String] Correct inflection of 'codes' and 'names'
2 parents b671312 + 7c953a4 commit c63584f

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

Constraints/BicValidator.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
*/
3030
class BicValidator extends ConstraintValidator
3131
{
32+
// Reference: https://www.iban.com/structure
3233
private const BIC_COUNTRY_TO_IBAN_COUNTRY_MAP = [
33-
// Reference: https://www.ecbs.org/iban/france-bank-account-number.html
34+
// FR includes:
3435
'GF' => 'FR', // French Guiana
3536
'PF' => 'FR', // French Polynesia
3637
'TF' => 'FR', // French Southern Territories
@@ -39,13 +40,20 @@ class BicValidator extends ConstraintValidator
3940
'YT' => 'FR', // Mayotte
4041
'NC' => 'FR', // New Caledonia
4142
'RE' => 'FR', // Reunion
43+
'BL' => 'FR', // Saint Barthelemy
44+
'MF' => 'FR', // Saint Martin (French part)
4245
'PM' => 'FR', // Saint Pierre and Miquelon
4346
'WF' => 'FR', // Wallis and Futuna Islands
44-
// Reference: https://www.ecbs.org/iban/united-kingdom-uk-bank-account-number.html
47+
// GB includes:
4548
'JE' => 'GB', // Jersey
4649
'IM' => 'GB', // Isle of Man
4750
'GG' => 'GB', // Guernsey
4851
'VG' => 'GB', // British Virgin Islands
52+
// FI includes:
53+
'AX' => 'FI', // Aland Islands
54+
// ES includes:
55+
'IC' => 'ES', // Canary Islands
56+
'EA' => 'ES', // Ceuta and Melilla
4957
];
5058

5159
private ?PropertyAccessor $propertyAccessor;
@@ -101,7 +109,8 @@ public function validate(mixed $value, Constraint $constraint)
101109
return;
102110
}
103111

104-
if (!Countries::exists(substr($canonicalize, 4, 2))) {
112+
$bicCountryCode = substr($canonicalize, 4, 2);
113+
if (!isset(self::BIC_COUNTRY_TO_IBAN_COUNTRY_MAP[$bicCountryCode]) && !Countries::exists($bicCountryCode)) {
105114
$this->context->buildViolation($constraint->message)
106115
->setParameter('{{ value }}', $this->formatValue($value))
107116
->setCode(Bic::INVALID_COUNTRY_CODE_ERROR)
@@ -134,7 +143,7 @@ public function validate(mixed $value, Constraint $constraint)
134143
return;
135144
}
136145
$ibanCountryCode = substr($iban, 0, 2);
137-
if (ctype_alpha($ibanCountryCode) && !$this->bicAndIbanCountriesMatch(substr($canonicalize, 4, 2), $ibanCountryCode)) {
146+
if (ctype_alpha($ibanCountryCode) && !$this->bicAndIbanCountriesMatch($bicCountryCode, $ibanCountryCode)) {
138147
$this->context->buildViolation($constraint->ibanMessage)
139148
->setParameter('{{ value }}', $this->formatValue($value))
140149
->setParameter('{{ iban }}', $iban)

Resources/translations/validators.de.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,10 @@
402402
<source>The value of the netmask should be between {{ min }} and {{ max }}.</source>
403403
<target>Der Wert der Subnetzmaske sollte zwischen {{ min }} und {{ max }} liegen.</target>
404404
</trans-unit>
405+
<trans-unit id="104">
406+
<source>The filename is too long. It should have {{ filename_max_length }} character or less.|The filename is too long. It should have {{ filename_max_length }} characters or less.</source>
407+
<target>Der Dateiname ist zu lang. Er sollte nicht länger als {{ filename_max_length }} Zeichen sein.|Der Dateiname ist zu lang. Er sollte nicht länger als {{ filename_max_length }} Zeichen sein.</target>
408+
</trans-unit>
405409
</body>
406410
</file>
407411
</xliff>

Resources/translations/validators.en.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,10 @@
402402
<source>The value of the netmask should be between {{ min }} and {{ max }}.</source>
403403
<target>The value of the netmask should be between {{ min }} and {{ max }}.</target>
404404
</trans-unit>
405+
<trans-unit id="104">
406+
<source>The filename is too long. It should have {{ filename_max_length }} character or less.|The filename is too long. It should have {{ filename_max_length }} characters or less.</source>
407+
<target>The filename is too long. It should have {{ filename_max_length }} character or less.|The filename is too long. It should have {{ filename_max_length }} characters or less.</target>
408+
</trans-unit>
405409
</body>
406410
</file>
407411
</xliff>

Tests/Constraints/BicValidatorTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ public static function getValidBicSpecialCases()
288288
yield ['BNPAYTGX', 'FR14 2004 1010 0505 0001 3M02 606'];
289289
yield ['BNPANCGX', 'FR14 2004 1010 0505 0001 3M02 606'];
290290
yield ['BNPAREGX', 'FR14 2004 1010 0505 0001 3M02 606'];
291+
yield ['BNPABLGX', 'FR14 2004 1010 0505 0001 3M02 606'];
292+
yield ['BNPAMFGX', 'FR14 2004 1010 0505 0001 3M02 606'];
291293
yield ['BNPAPMGX', 'FR14 2004 1010 0505 0001 3M02 606'];
292294
yield ['BNPAWFGX', 'FR14 2004 1010 0505 0001 3M02 606'];
293295

@@ -296,6 +298,13 @@ public static function getValidBicSpecialCases()
296298
yield ['BARCIMSA', 'GB12 CPBK 0892 9965 0449 911'];
297299
yield ['BARCGGSA', 'GB12 CPBK 0892 9965 0449 911'];
298300
yield ['BARCVGSA', 'GB12 CPBK 0892 9965 0449 911'];
301+
302+
// FI related special cases
303+
yield ['NDEAAXHH', 'FI14 1009 3000 1234 58'];
304+
305+
// ES related special cases
306+
yield ['CAIXICBBXXX', 'ES79 2100 0813 6101 2345 6789'];
307+
yield ['CAIXEABBXXX', 'ES79 2100 0813 6101 2345 6789'];
299308
}
300309
}
301310

0 commit comments

Comments
 (0)