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(niceToHave): Export list of country codes that implement IBAN #1669

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/index.js
Expand Up @@ -48,7 +48,7 @@ import isHSL from './lib/isHSL';

import isISRC from './lib/isISRC';

import isIBAN from './lib/isIBAN';
import isIBAN, { locales as ibanLocales } from './lib/isIBAN';
import isBIC from './lib/isBIC';

import isMD5 from './lib/isMD5';
Expand Down Expand Up @@ -222,6 +222,7 @@ const validator = {
isDate,
isLicensePlate,
isVAT,
ibanLocales,
};

export default validator;
2 changes: 2 additions & 0 deletions src/lib/isIBAN.js
Expand Up @@ -135,3 +135,5 @@ export default function isIBAN(str) {

return hasValidIbanFormat(str) && hasValidIbanChecksum(str);
}

export const locales = Object.keys(ibanRegexThroughCountryCode);
6 changes: 6 additions & 0 deletions test/exports.js
Expand Up @@ -5,6 +5,7 @@ import { locales as isAlphaLocales } from '../src/lib/isAlpha';
import { locales as isAlphanumericLocales } from '../src/lib/isAlphanumeric';
import { locales as isMobilePhoneLocales } from '../src/lib/isMobilePhone';
import { locales as isFloatLocales } from '../src/lib/isFloat';
import { locales as ibanCountryCodes } from '../src/lib/isIBAN';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import { locales as ibanCountryCodes } from '../src/lib/isIBAN';
import { locales as isIBANLocales } from '../src/lib/isIBAN';

I would name it isIBANLocales to align to the other one.


describe('Exports', () => {
it('should export validators', () => {
Expand Down Expand Up @@ -50,4 +51,9 @@ describe('Exports', () => {
assert.ok(isFloatLocales instanceof Array);
assert.ok(validator.isFloatLocales instanceof Array);
});

it('should export a list of country codes that implement IBAN', () => {
assert.ok(ibanCountryCodes instanceof Array);
assert.ok(validator.ibanLocales instanceof Array);
});
});