Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/isIBAN.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const ibanRegexThroughCountryCode = {
GT: /^(GT[0-9]{2})[A-Z0-9]{4}[A-Z0-9]{20}$/,
HR: /^(HR[0-9]{2})\d{17}$/,
HU: /^(HU[0-9]{2})\d{24}$/,
IE: /^(IE[0-9]{2})[A-Z0-9]{4}\d{14}$/,
IE: /^(IE[0-9]{2})[A-Z]{4}\d{14}$/,
IL: /^(IL[0-9]{2})\d{19}$/,
IQ: /^(IQ[0-9]{2})[A-Z]{4}\d{15}$/,
IR: /^(IR[0-9]{2})0\d{2}0\d{18}$/,
Expand Down Expand Up @@ -67,7 +67,7 @@ const ibanRegexThroughCountryCode = {
NO: /^(NO[0-9]{2})\d{11}$/,
PK: /^(PK[0-9]{2})[A-Z0-9]{4}\d{16}$/,
PL: /^(PL[0-9]{2})\d{24}$/,
PS: /^(PS[0-9]{2})[A-Z0-9]{4}\d{21}$/,
PS: /^(PS[0-9]{2})[A-Z]{4}\d{21}$/,
Copy link
Contributor

Choose a reason for hiding this comment

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

Kindly correct me, but If I understand this correctly, the Palestine RegExp would be wrong here (the last part):

On page 6 of the supplied PDF we can see the convention:
grafik

The supplied PDF says the IBAN structure is PS2!n4!a21!c
The regex here shows /^(PS[0-9]{2})[A-Z]{4}\d{21}$/

So I would argue, that the \d{21} part should actually be [a-zA-Z0-9] or [A-Z0-9] (since we don't care about case, I think).

what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I was focused on the first part of the regex since it was the one that gave me trouble 😄.

As for the [a-zA-Z0-9] or [A-Z0-9] part, I've adjusted regex to include only capital letters, since from what I was able to gather IBAN should be case-insensitive and we're already converting everything to uppercase. I've added a test case that includes a letter as well.

PT: /^(PT[0-9]{2})\d{21}$/,
QA: /^(QA[0-9]{2})[A-Z]{4}[A-Z0-9]{21}$/,
RO: /^(RO[0-9]{2})[A-Z]{4}[A-Z0-9]{16}$/,
Expand Down
4 changes: 4 additions & 0 deletions test/validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5857,6 +5857,8 @@ describe('Validators', () => {
'MA64011519000001205000534921',
'VG96VPVG0000012345678901',
'DZ580002100001113000000570',
'IE29AIBK93115212345678',
'PS92PALS000000000400123456702',
],
invalid: [
'XX22YYY1234567890123',
Expand All @@ -5865,6 +5867,8 @@ describe('Validators', () => {
'FR7630006000011234567890189😅',
'FR763000600001123456!!🤨7890189@',
'VG46H07Y0223060094359858',
'IE95TE8270900834048660',
'PS072435171802145240705922007',
],
});
test({
Expand Down
Loading