Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/lib/isIdentityCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,12 @@ const validators = {
}, 0);
},
PK: (str) => {
// Pakistani National Identity Number CNIC is 13 digits
const CNIC = /^[1-7][0-9]{4}-[0-9]{7}-[1-9]$/;
// Pakistani National Identity Number CNIC is 13 digits in the form
// XXXXX-XXXXXXX-X. The first digit is the province/administrative-unit
// code 1-8 (8 = Azad Kashmir) and the last digit encodes gender, using
// odd digits for men and even digits (including 0) for women.
// https://en.wikipedia.org/wiki/CNIC_(Pakistan)
const CNIC = /^[1-8][0-9]{4}-[0-9]{7}-[0-9]$/;

// sanitize user input
const sanitized = str.trim();
Expand Down
4 changes: 4 additions & 0 deletions test/validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6685,6 +6685,10 @@ describe('Validators', () => {
'63456-8765432-8',
'55672-1234567-5',
'21234-9876543-6',
'82345-2345678-7',
'81234-1234567-3',
'45504-4185771-0',
'34543-2323471-0',
],
invalid: [
'08000-1234567-5',
Expand Down
Loading