Skip to content

Commit 7ab06c4

Browse files
authored
fix(isPassportNumber): improve CA locale (#2526)
- Regex now covers both of the following patterns: - Old pattern of: 2 letters, followed by 6 digits - New pattern of: 1 letter, 6 digits, 2 letters
1 parent ac3d50a commit 7ab06c4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/lib/isPassportNumber.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const passportRegexByCountryCode = {
1616
BG: /^\d{9}$/, // BULGARIA
1717
BR: /^[A-Z]{2}\d{6}$/, // BRAZIL
1818
BY: /^[A-Z]{2}\d{7}$/, // BELARUS
19-
CA: /^[A-Z]{2}\d{6}$/, // CANADA
19+
CA: /^[A-Z]{2}\d{6}$|^[A-Z]\d{6}[A-Z]{2}$/, // CANADA
2020
CH: /^[A-Z]\d{7}$/, // SWITZERLAND
2121
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
2222
CY: /^[A-Z](\d{6}|\d{8})$/, // CYPRUS

test/validators.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,9 +2956,17 @@ describe('Validators', () => {
29562956
valid: [
29572957
'GA302922',
29582958
'ZE000509',
2959+
'A123456AB',
2960+
'Z556378HG',
29592961
],
29602962
invalid: [
29612963
'AB0123456',
2964+
'AZ556378H',
2965+
'556378HCX',
2966+
'556378432',
2967+
'5563784',
2968+
'#B12345FD',
2969+
'A43F12354',
29622970
],
29632971
});
29642972

0 commit comments

Comments
 (0)