Skip to content

Commit 6b550a1

Browse files
bug symfony#54219 [Validator] Allow BICs’ first four characters to be digits (MatTheCat)
This PR was merged into the 5.4 branch. Discussion ---------- [Validator] Allow BICs’ first four characters to be digits | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix symfony#51975 | License | MIT While a lot of sources claim a BIC’s first four characters must be letters, this is not the case since ISO 9362:1994. The confusion may come from SWIFT (ISO 9362’s registration authority) saying that > [We have] no plan to issue BICs with numeric characters in the first 4 characters. [Source](https://www.swift.com/swift-resource/9586/download) (clicking this link will trigger a download) However, the next paragraph says > If applications have implemented restrictions on the allowed characters, it would be good practice to remove this restriction at the occasion of a software update to respect the standard specification of 4 alpha-numeric characters. As `@luxemate` stumbled on such a valid BIC (see linked issue), this PR removes the `Bic::INVALID_BANK_CODE_ERROR` check. This constant won’t be referenced anymore so it may be deprecated and removed later. Commits ------- 0d824a7 [Validator] Allow BICs’ first four characters to be digits
2 parents 43d643b + 0d824a7 commit 6b550a1

File tree

2 files changed

+1
-16
lines changed

2 files changed

+1
-16
lines changed

src/Symfony/Component/Validator/Constraints/BicValidator.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,6 @@ public function validate($value, Constraint $constraint)
102102
return;
103103
}
104104

105-
// first 4 letters must be alphabetic (bank code)
106-
if (!ctype_alpha(substr($canonicalize, 0, 4))) {
107-
$this->context->buildViolation($constraint->message)
108-
->setParameter('{{ value }}', $this->formatValue($value))
109-
->setCode(Bic::INVALID_BANK_CODE_ERROR)
110-
->addViolation();
111-
112-
return;
113-
}
114-
115105
$bicCountryCode = substr($canonicalize, 4, 2);
116106
if (!isset(self::BIC_COUNTRY_TO_IBAN_COUNTRY_MAP[$bicCountryCode]) && !Countries::exists($bicCountryCode)) {
117107
$this->context->buildViolation($constraint->message)

src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,14 @@ public function testValidBics($bic)
199199

200200
public static function getValidBics()
201201
{
202-
// http://formvalidation.io/validators/bic/
203202
return [
204203
['ASPKAT2LXXX'],
205204
['ASPKAT2L'],
206205
['DSBACNBXSHA'],
207206
['UNCRIT2B912'],
208207
['DABADKKK'],
209208
['RZOOAT2L303'],
209+
['1SBACNBXSHA'],
210210
];
211211
}
212212

@@ -252,11 +252,6 @@ public static function getInvalidBics()
252252
['ASPKAT2LX', Bic::INVALID_LENGTH_ERROR],
253253
['ASPKAT2LXXX1', Bic::INVALID_LENGTH_ERROR],
254254
['DABADKK', Bic::INVALID_LENGTH_ERROR],
255-
['1SBACNBXSHA', Bic::INVALID_BANK_CODE_ERROR],
256-
['RZ00AT2L303', Bic::INVALID_BANK_CODE_ERROR],
257-
['D2BACNBXSHA', Bic::INVALID_BANK_CODE_ERROR],
258-
['DS3ACNBXSHA', Bic::INVALID_BANK_CODE_ERROR],
259-
['DSB4CNBXSHA', Bic::INVALID_BANK_CODE_ERROR],
260255
['DEUT12HH', Bic::INVALID_COUNTRY_CODE_ERROR],
261256
['DSBAC6BXSHA', Bic::INVALID_COUNTRY_CODE_ERROR],
262257
['DSBA5NBXSHA', Bic::INVALID_COUNTRY_CODE_ERROR],

0 commit comments

Comments
 (0)