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

feat: implement isIBAN(str) validator #1243

Merged
merged 2 commits into from
Feb 1, 2020

Conversation

hamzahejja
Copy link
Contributor

@hamzahejja hamzahejja commented Jan 29, 2020

@hamzahejja hamzahejja mentioned this pull request Jan 30, 2020
Copy link
Member

@profnandaa profnandaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally solid work on this one, thanks for your contrib! 🎉 Just a few comments from me.

lib/isIBAN.js Outdated
* Reference: https://en.wikipedia.org/wiki/International_Bank_Account_Number
*/
var ibanRegexThroughCountryCode = {
AL: /^(AL[0-9]{2})\d{8}[A-Z0-9]{16}$/,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you re-arrange these codes in alphabetical order to make it easy for reading and later contributions?

var strippedStr = str.replace(/[^A-Z0-9]+/gi, '').toUpperCase(); // Keep only digits and A-Z latin alphabetic

var rearranged = strippedStr.slice(4) + strippedStr.slice(0, 4);
var alphaCapsReplacedWithDigits = rearranged.replace(/[A-Z]/g, function (char) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could make use of the ES6 features here for code succinctness if you don't mind, eg.

.replace(/[A-Z]/g, char => char.charCodeAt(0) - 55);

Same to line 133.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@profnandaa Thanks for your feedback! I'm already using ES6 features for code succinctness (i.e. arrow functions) in both of the locations you've pointed-out back in src/lib/isIBAN.js where the implementation lies, see here: https://github.com/validatorjs/validator.js/pull/1243/files#diff-ce49d7aaa9466099bb72b0307133b63dR121-R124

the above file lib/isIBAN.js is auto-generated when running tests through npm test, as the #CONTRIBUTING sections of README.md implies:

files in lib/ folder are autogenerated when running tests (npm test) and need not to be changed manually.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my bad. I reviewed the wrong part of code. You are right, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@profnandaa No problem! All is good 👍

Copy link
Member

@profnandaa profnandaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@profnandaa profnandaa merged commit b331b5a into validatorjs:master Feb 1, 2020
@hamzahejja hamzahejja deleted the isIBAN-validation branch February 1, 2020 15:54
@profnandaa profnandaa mentioned this pull request Feb 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants