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(isPassportNumber): fix regex for CN #1714

Merged
merged 2 commits into from Sep 26, 2021

Conversation

anirudhgiri
Copy link
Contributor

Fixes #1686

The format for passport numbers for CN passports are as follows:

  • Starts with either a "G" (for Ordinary) or an "E" (for Electronic)
  • If it starts with "G", 8 numbers follow
  • If it starts with "E" either 8 numbers follow, or a letter [A-Z] (except "I" or "O") and 7 numbers follow

Valid Examples:

  • G12345678
  • E12345678
  • EA1234567

So the above conditions were implemented with the following regex : ^G\d{8}$|^E(?![IO])[A-Z0-9]\d{7}$

The appropriate testes were added to validators.js with all of them passing.

Checklist

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

@codecov
Copy link

codecov bot commented Aug 20, 2021

Codecov Report

Merging #1714 (606c8cd) into master (8c4b3b3) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1714   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          101       101           
  Lines         2005      2005           
  Branches       452       452           
=========================================
  Hits          2005      2005           
Impacted Files Coverage Δ
src/lib/isPassportNumber.js 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c4b3b3...606c8cd. Read the comment docs.

@anirudhgiri
Copy link
Contributor Author

Bump!
It's been 48 hours since I opened the PR and no one has reviewed it. Just making sure 😄

Copy link
Member

@tux-tn tux-tn left a comment

Choose a reason for hiding this comment

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

Really sorry for the long delay @anirudhgiri ! Thank you for your PR 🎉
LGTM !

@tux-tn tux-tn added ready-to-land For PRs that are reviewed and ready to be landed 🎉 first-pr labels Sep 20, 2021
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, thanks for your contrib! 🎉

@profnandaa profnandaa merged commit 69881b6 into validatorjs:master Sep 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 first-pr ready-to-land For PRs that are reviewed and ready to be landed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

isPassportNumber isnot exactlly
3 participants