Skip to content

Commit 2c5b8d5

Browse files
committed
Add Norwegian passport validation
The regex is constructed based on the Norwegian Police's control guide: https://www.politiet.no/globalassets/tjenester-admin/pass-og-id-kort/control-guide-for-norwegian-passports.pdf (ISBN 978-82-8256-097-9). It matches Norwegian passport numbers starting with C, K, or FG, FH, FJ, FL, and FK prefixes, followed by alphanumeric characters. The guide is not very detailed. It does not specify passport number length, so this is not validated.
1 parent f2e3633 commit 2c5b8d5

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/lib/isPassportNumber.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const passportRegexByCountryCode = {
5252
MY: /^[AHK]\d{8}$/, // MALAYSIA
5353
MX: /^\d{10,11}$/, // MEXICO
5454
NL: /^[A-Z]{2}[A-Z0-9]{6}\d$/, // NETHERLANDS
55+
NO: /^(C|K|FG|FH|FJ|FL|FK)[A-Z0-9]+/, // NORWAY
5556
NZ: /^([Ll]([Aa]|[Dd]|[Ff]|[Hh])|[Ee]([Aa]|[Pp])|[Nn])\d{6}$/, // NEW ZEALAND
5657
PH: /^([A-Z](\d{6}|\d{7}[A-Z]))|([A-Z]{2}(\d{6}|\d{7}))$/, // PHILIPPINES
5758
PK: /^[A-Z]{2}\d{7}$/, // PAKISTAN

test/validators.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,6 +3825,16 @@ describe('Validators', () => {
38253825
'XR1001R58A',
38263826
],
38273827
});
3828+
test({
3829+
validator: 'isPassportNumber',
3830+
args: ['NO'],
3831+
valid: [
3832+
'CCC002151',
3833+
],
3834+
invalid: [
3835+
'P12345678',
3836+
],
3837+
});
38283838
test({
38293839
validator: 'isPassportNumber',
38303840
args: ['PK'],

0 commit comments

Comments
 (0)