Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Validator] Add allowSpaces and allowLowerCase option in IBAN/BIC constraints #30272

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

Closed
wants to merge 2 commits into from

Conversation

alamirault
Copy link
Contributor

@alamirault alamirault commented Feb 16, 2019

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #28232
License MIT
Doc PR symfony/symfony-docs#11000

This PR allow to add options for BIC and IBAN constraints. I added allowSpaces and allowLowerCase options.
By default BIC allow spaces and disallow lower case, IBAN allow spaces and allow lower case.
It not same in order to avoid BC.

@OskarStark
Copy link
Contributor

You could validate a BIC and IBAN against each other, is it still possible when using different options on BIC and IBAN?

@nicolas-grekas nicolas-grekas added this to the next milestone Feb 17, 2019
@alamirault
Copy link
Contributor Author

Tests certainly failed due to merge in twig repo, maybe twigphp/Twig#2848 ?

@javiereguiluz
Copy link
Member

I've been checking the case-sensitivity details for BIC and IBAN, which is surprisingly hard to find:

  1. IBAN: 2 uppercase letters for the country + 2 digits + up to 30 alphanumeric characters for the bank account number. The last 30-character part is case-insensitive: https://en.wikipedia.org/wiki/International_Bank_Account_Number
  2. BIC: it's not clear. The standard doesn't mention it: https://www.swift.com/standards/data-standards/bic#BICvalidationUserGuide but all validator you can find in other languages assume that it's case-sensitive and only uppercase letters are accepted. This (big) PDF contains the full list of all valid BIC codes in the world. All of them are uppercase: https://www.iso9362.org/documents/ISOBIC.pdf

So, I don't think we should make the case-sensitive behavior an option. This is a BIC + IBAN validator ... we cannot change those standards to validate what we want.

@ro0NL
Copy link
Contributor

ro0NL commented Feb 18, 2019

So perhaps it's better to leverage #26484 in userland..

@nicolas-grekas
Copy link
Member

Always the same story: are validators also normalizers? If one wants to validate that it has only already normalized values in their db, then the check would be case sensitive and it should fail on whitespaces. Now, if one wants to accept user input and be robust (following the robustness principle), then the validator should accept both spaces and lowercase letters, and normalize them to uppercase+spaceless.

Both approaches are valid. Which domain is covered by this class?

@fabpot
Copy link
Member

fabpot commented Feb 21, 2019

A validator should only validate the official way. So, adding options to deviate from that is a no go to me.

@nicolas-grekas
Copy link
Member

Thank you @alamirault
I'm going to close as explained.
On my side, I think we should make a clear distinction when the validator is in "strict" vs "filtering" mode.
That should be a concept that applies to almost all validators. (strict means the input is exactly the same as the output, after normalization)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants