Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Validator] Allow BICs’ first four characters to be digits #54219

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/Symfony/Component/Validator/Constraints/BicValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,14 @@ public function testValidBics($bic)

public static function getValidBics()
{
// http://formvalidation.io/validators/bic/
return [
['ASPKAT2LXXX'],
['ASPKAT2L'],
['DSBACNBXSHA'],
['UNCRIT2B912'],
['DABADKKK'],
['RZOOAT2L303'],
['1SBACNBXSHA'],
];
}

Expand Down Expand Up @@ -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],
Expand Down