Skip to content

Commit 69881b6

Browse files
authored
feat(isPassportNumber): fix regex for CN (#1714)
* fix: (isPassportNumber) fix regex for CN * feat(isPassportNumber): fix regex for CN (#1686)
1 parent b0d49bd commit 69881b6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/lib/isPassportNumber.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const passportRegexByCountryCode = {
1717
BY: /^[A-Z]{2}\d{7}$/, // BELARUS
1818
CA: /^[A-Z]{2}\d{6}$/, // CANADA
1919
CH: /^[A-Z]\d{7}$/, // SWITZERLAND
20-
CN: /^[GE]\d{8}$/, // CHINA [G=Ordinary, E=Electronic] followed by 8-digits
20+
CN: /^G\d{8}$|^E(?![IO])[A-Z0-9]\d{7}$/, // CHINA [G=Ordinary, E=Electronic] followed by 8-digits, or E followed by any UPPERCASE letter (except I and O) followed by 7 digits
2121
CY: /^[A-Z](\d{6}|\d{8})$/, // CYPRUS
2222
CZ: /^\d{8}$/, // CZECH REPUBLIC
2323
DE: /^[CFGHJKLMNPRTVWXYZ0-9]{9}$/, // GERMANY

test/validators.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2475,9 +2475,15 @@ describe('Validators', () => {
24752475
valid: [
24762476
'G25352389',
24772477
'E00160027',
2478+
'EA1234567',
24782479
],
24792480
invalid: [
24802481
'K0123456',
2482+
'E-1234567',
2483+
'G.1234567',
2484+
'GA1234567',
2485+
'EI1234567',
2486+
'GO1234567',
24812487
],
24822488
});
24832489

0 commit comments

Comments
 (0)