Skip to content

Commit

Permalink
fix irish and slovak passport validation (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
ogonzi authored Aug 30, 2024
1 parent c803849 commit 49ff9eb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "id-doc-validator",
"version": "0.7.4",
"version": "1.0.0",
"homepage": "https://github.com/necesito-un-trastero/id-doc-validator",
"description": "A validator for different types of personal ID for multiple countries.",
"main": "src/index.js",
Expand Down
7 changes: 5 additions & 2 deletions src/__tests__/type_validations/passport.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ describe("validatePassport(IE)", () => {
it("should return false for an invalid passport", () => {
expect(validatePassport("K1234567", "IE")).toBe(false);
expect(validatePassport("PLA123456", "IE")).toBe(false);
expect(validatePassport("ZA1234567", "IE")).toBe(false);
expect(validatePassport("1234567", "IE")).toBe(false);
expect(validatePassport("PA123456", "IE")).toBe(false);
expect(validatePassport("PA12345678", "IE")).toBe(false);
expect(validatePassport("PA 1234568", "IE")).toBe(false);
Expand All @@ -280,6 +280,8 @@ describe("validatePassport(IE)", () => {
it("should return true for a valid passport", () => {
expect(validatePassport("PA1234567", "IE")).toBe(true);
expect(validatePassport("LA1234567", "IE")).toBe(true);
expect(validatePassport("L11234567", "IE")).toBe(true);
expect(validatePassport("111234567", "IE")).toBe(true);
});
});

Expand Down Expand Up @@ -456,7 +458,7 @@ describe("validatePassport(SE)", () => {
describe("validatePassport(SK)", () => {
it("should return false for an invalid passport", () => {
expect(validatePassport("1234567", "SK")).toBe(false);
expect(validatePassport("123456789", "SK")).toBe(false);
expect(validatePassport("1234567890", "SK")).toBe(false);
expect(validatePassport("A123456", "SK")).toBe(false);
expect(validatePassport("SE123456", "SK")).toBe(false);
expect(validatePassport("123-456.78", "SK")).toBe(false);
Expand All @@ -465,6 +467,7 @@ describe("validatePassport(SK)", () => {
it("should return true for a valid passport", () => {
expect(validatePassport("12345678", "SK")).toBe(true);
expect(validatePassport("a1234567", "SK")).toBe(true);
expect(validatePassport("AB7654321", "SK")).toBe(true);
});
});

Expand Down
4 changes: 2 additions & 2 deletions src/type_validations/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const passportRegexByCountryCodeMap = {
GR: /^[A-Z]{2}\d{7}$/,
HR: /^\d{9}$/,
HU: /^[A-Z]{2}\d{6,7}$/,
IE: /^[PL][A-Z]\d{7}$/,
IE: /^[0-9A-Z]{2}\d{7}$/,
IT: /^[0-9A-Z]{2}\d{7}$/,
LT: /^\d{8}$/,
LU: /^[A-Z0-9]{8}$/,
Expand All @@ -30,7 +30,7 @@ const passportRegexByCountryCodeMap = {
PT: /^[A-Z]\d{6}$/,
RO: /^\d{8,9}$/,
SE: /^\d{8}$/,
SK: /^[A-Z0-9]\d{7}$/,
SK: /^[A-Z0-9]{1,2}\d{7}$/,
SL: /^P[A-Z]\d{7}$/,
US: /^\d{9}$/,
};
Expand Down

0 comments on commit 49ff9eb

Please sign in to comment.