Skip to content

Conversation

@Tarasz57
Copy link
Contributor

@Tarasz57 Tarasz57 commented Jan 16, 2025

Changes:

Palestine and Ireland IBAN's should consist of countryCode followed by 2 numbers and then 4 [A-Z] symbols, not [A-Z0-9]. This PR adjusts these 2 regexes to follow the required standard.

Sources:

According to Swift documentation, specifically this file here

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable)
  • References provided in PR (where applicable)

@WikiRik
Copy link
Member

WikiRik commented Jan 16, 2025

Thanks for this PR. I was able to verify that your changes seem correct. Can you add some test cases so we don't accidentally change it back?

@Tarasz57
Copy link
Contributor Author

Tarasz57 commented Jan 16, 2025

Of course. I've updated the tests to include both (previously) invalid and now correct IBAN's for both of these countries.

WikiRik
WikiRik previously approved these changes Jan 16, 2025
@WikiRik WikiRik requested review from pano9000 and rubiin January 16, 2025 19:51
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.

@rubiin rubiin merged commit a1e8476 into validatorjs:master Jan 17, 2025
10 checks passed
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.

4 participants