Validator.js: isIBAN & isBIC

Created on 19 Dec 2018  路  8Comments  路  Source: validatorjs/validator.js

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

Thank you .

good first issue hacktoberfest help wanted 馃檵鈥嶁檪锔廸eature-request

All 8 comments

I'm working right now on isIBAN

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

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.

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

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

@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

@ezkemboi pull request created! thanks

This issue seems to be resolved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mren picture mren  路  3Comments

AnandChowdhary picture AnandChowdhary  路  3Comments

galki picture galki  路  3Comments

malkhuzayyim picture malkhuzayyim  路  4Comments

Maxreglez picture Maxreglez  路  3Comments