Skip to content

Commit

Permalink
fix: add historic id in check fn
Browse files Browse the repository at this point in the history
  • Loading branch information
stumpam committed Jan 4, 2023
1 parent 12a3764 commit 0a67583
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libs/ngx-cz-id/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@stumpam/ngx-cz-id",
"license": "MIT",
"version": "3.2.2",
"version": "3.2.3",
"description": "Angular input for czech id (Rodné číslo) with validation.",
"homepage": "https://github.com/stumpam/ngx-cz-id",
"author": "Martin Štumpa (https://github.com/stumpam)",
Expand Down
6 changes: 2 additions & 4 deletions libs/ngx-cz-id/src/lib/functions/check.functions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { padStart } from '../functions/format.functions';

const nextYear = new Date().getFullYear() - 1999;

export function isValidCzId(id: string): boolean {
const normalizedId = id.replace('/', '');
const { year, month, day, num } = splitIdString(normalizedId);
Expand Down Expand Up @@ -58,7 +56,7 @@ export function checkId(
return false;
}

return y < 54 && y > nextYear ? true : checkSum(year, month, day, num);
return historicId ? true : checkSum(year, month, day, num);
}

function checkSum(
Expand Down Expand Up @@ -107,6 +105,6 @@ export function splitIdString(str: string) {
year,
month: str?.slice(2, 4),
day: str?.slice(4, 6),
num: str?.slice(6, +year < 54 && +year > nextYear ? 9 : 10),
num: str?.slice(6),
};
}

0 comments on commit 0a67583

Please sign in to comment.