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

isIBAN & isBIC #951

Closed
ghost opened this issue Dec 19, 2018 · 8 comments
Closed

isIBAN & isBIC #951

ghost opened this issue Dec 19, 2018 · 8 comments

Comments

@ghost
Copy link

ghost commented Dec 19, 2018

Could you implement those function inside the validator ?
Those would be very usefull .

Thank you .

@NizarGhazouani
Copy link

I'm working right now on isIBAN

@ezkemboi
Copy link
Member

I will check on @NizarGhazouani PR. Though, it seems, it needs some updates.
Thanks for suggestion @PaulBenabou.
I will also try to work on isBIC/isSWIFT in another PR some day later.

But, if someone wants to check on it, here are some notes/guidelines.

SWIFT / BIC codes should contain the following:

a 4-letter bank code
a 2-letter country code
a 2-letter or number location code
a 3-letter or number branch code (optional)

cc. @profnandaa

@ezkemboi
Copy link
Member

I will also see that, I can work on validating the isBIC as general.
Then, we can add options where the user can validate based on country.
Then, if someone makes a suggestion in the future in terms of location validates, we can do discussions on the same.

ezkemboi added a commit to ezkemboi/validator.js that referenced this issue Jul 28, 2019
- validate valid BIC
- refers part of validatorjs#951
ezkemboi added a commit to ezkemboi/validator.js that referenced this issue Jul 28, 2019
- validate valid BIC
- refers part of validatorjs#951
ezkemboi added a commit to ezkemboi/validator.js that referenced this issue Aug 11, 2019
- fix linter issues
- fix tests
- seperate unnecessary files changes
- closes validatorjs#1034 validatorjs#951
- Other references validatorjs#1071
ezkemboi added a commit to ezkemboi/validator.js that referenced this issue Aug 11, 2019
- fix linter issues
- fix tests
- seperate unnecessary files changes
- closes validatorjs#1034 validatorjs#951
- Other references validatorjs#1071
ezkemboi added a commit to ezkemboi/validator.js that referenced this issue Aug 11, 2019
- fix linter issues
- fix tests
- seperate unnecessary files changes
- closes validatorjs#1034 validatorjs#951
- Other references validatorjs#1071
ezkemboi added a commit to ezkemboi/validator.js that referenced this issue Aug 11, 2019
- fix linter issues
- fix tests
- seperate unnecessary files changes
- closes validatorjs#1034 validatorjs#951
- Other references validatorjs#1071
ezkemboi added a commit to ezkemboi/validator.js that referenced this issue Aug 12, 2019
- validate valid BIC
- refers part of validatorjs#951
profnandaa pushed a commit that referenced this issue Aug 17, 2019
* feature(isBIC): add isBIC validation
- validate valid BIC
- refers part of #951

* chore: add on BIC definition
@hamzahejja
Copy link
Contributor

hamzahejja commented Jan 30, 2020

@profnandaa @ezkemboi PR #1243 introduces an implementation to the isIBAN(str) validation, kindly check it please when you have the time.

@GoMino
Copy link
Contributor

GoMino commented Mar 11, 2020

It's seems to be possible to add emojis or any special character (!@#...) to the IBAN, and it will still pass the validation, could you fix this ?
However, the validation seems to work correctly for isBIC()

The following function in isIBAN.js seems buggy:

function hasValidIbanFormat(str) {
  // Strip white spaces and hyphens, keep only digits and A-Z latin alphabetic
  const strippedStr = str.replace(/[^A-Z0-9]+/gi, '').toUpperCase();
  const isoCountryCode = strippedStr.slice(0, 2).toUpperCase();

  return (isoCountryCode in ibanRegexThroughCountryCode) &&
      ibanRegexThroughCountryCode[isoCountryCode].test(strippedStr);
}

Why testing the stripped string ?
It would not test the initial string correctly, any special character or emojis will be stripped away, and validation may pass

@ezkemboi
Copy link
Member

@GoMino, I will try to reproduce that bug, but don't hesitate to raise a PR or solution in case you come across the best possible way to resolve the issue.

cc. @profnandaa

@GoMino
Copy link
Contributor

GoMino commented Mar 11, 2020

@ezkemboi pull request created! thanks

@parasg1999
Copy link
Contributor

This issue seems to be resolved.

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

7 participants