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

swiftBicNumber() generates BIC codes with invalid country codes #902

Closed
GJoffrey opened this issue Sep 26, 2024 · 1 comment
Closed

swiftBicNumber() generates BIC codes with invalid country codes #902

GJoffrey opened this issue Sep 26, 2024 · 1 comment

Comments

@GJoffrey
Copy link

GJoffrey commented Sep 26, 2024

Summary

The swiftBicNumber() function in FakerPHP generates BIC codes where the 5th and 6th characters, which should represent a valid country code according to the ISO 3166-1 alpha-2 standard, are entirely random.
This leads to validation failures when using validators that check for valid country codes in BICs, such as the one provided by Symfony (#[Assert\Bic]) based on a full table of ISO 3166 country codes that can be found here: https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes

Versions

Version
PHP 8.3
fakerphp/faker 1.23.1

Possible solution:

Modify the swiftBicNumber() function to generate the country code segment (positions 5 and 6) using a list of valid ISO 3166-1 alpha-2 country codes. This could involve:

  • Integrating an array of valid country codes into FakerPHP. (maybe Payment::$ibanFormats keys ?)
  • Adjusting the BIC generation logic to select a random valid country code for the relevant positions.

Thank you for addressing this issue. Please let me know if you require any further information.

vjandrea added a commit to vjandrea/Faker that referenced this issue Dec 8, 2024
- swiftBicNumber now accepts an optional $countryCode argument to localize the generated value
- using Symfony Validator in tests
vjandrea added a commit to vjandrea/Faker that referenced this issue Dec 9, 2024
- swiftBicNumber now accepts an optional $countryCode argument to localize the generated value
- using Symfony Validator in tests
vjandrea added a commit to vjandrea/Faker that referenced this issue Dec 9, 2024
- swiftBicNumber now accepts an optional $countryCode argument to localize the generated value
- using Symfony Validator in tests
vjandrea added a commit to vjandrea/Faker that referenced this issue Dec 9, 2024
- swiftBicNumber now accepts an optional $countryCode argument to localize the generated value
- using Symfony Validator in tests
vjandrea added a commit to vjandrea/Faker that referenced this issue Dec 9, 2024
- swiftBicNumber now accepts an optional $countryCode argument to localize the generated value
- using Symfony Validator in tests
Copy link

stale bot commented Jan 31, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 1 week if no further activity occurs. Thank you for your contributions.

@stale stale bot closed this as completed Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant