@remato/personal-code-to-birthday
Advanced tools
Comparing version 1.1.1 to 1.2.0
{ | ||
"name": "@remato/personal-code-to-birthday", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Converts personal identification codes from various countries into birthdate", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -6,6 +6,17 @@ # Personal Code to Birthday | ||
Converts personal identification codes (or national ID numbers) from various countries into birthdate. | ||
Converts personal identification codes from various countries into birthdate. | ||
### Install | ||
### Features | ||
- **Automatic Birthdate Extraction**: Effortlessly extracts birthdates from national ID codes. | ||
- **Built-in Validation**: Confirms personal code validity using checksum verification before returning a date. | ||
- **Country-Agnostic**: Automatically identifies and processes the country format, requiring no additional parameters. | ||
- **Lightweight & Seamless Integration**: Designed for easy integration into any project with minimal setup. | ||
### Limitations | ||
- **Date Range Restriction**: Only supports personal codes issued from 1900 to the present. Future-dated codes are not currently supported. | ||
### Installation | ||
```bash | ||
@@ -15,3 +26,3 @@ npm install @remato/personal-code-to-birthday | ||
### How to use | ||
### Usage | ||
@@ -26,26 +37,13 @@ ```ts | ||
- 🇪🇪 Estonia | ||
- 🇱🇻 Latvia | ||
- 🇱🇹 Lithuania | ||
- 🇫🇮 Finland | ||
- 🇸🇪 Sweden | ||
- 🇳🇴 Norway | ||
- 🇩🇰 Denmark | ||
- 🇺🇦 Ukraine | ||
- 🇵🇱 Poland | ||
1. 🇺🇦 Ukraine | ||
2. 🇪🇪 Estonia | ||
3. 🇱🇻 Latvia | ||
4. 🇱🇹 Lithuania | ||
5. 🇵🇱 Poland | ||
6. 🇫🇮 Finland | ||
7. 🇸🇪 Sweden | ||
8. 🇳🇴 Norway | ||
9. 🇩🇰 Denmark | ||
10. 🇷🇴 Romania | ||
Countries we would like to support (PRs are welcome): | ||
- Iceland | ||
- Romania | ||
- Hungary | ||
- Bulgaria | ||
- Moldova | ||
- Azerbaijan | ||
- North Macedonia | ||
- Czech Republic | ||
- Slovakia | ||
- South Korea | ||
- Turkey | ||
- South Africa | ||
- Russia | ||
Need support for a new country or have feedback? [Create an issue.](https://github.com/rematocorp/personal-code-to-birthday/issues/new) |
@@ -61,2 +61,8 @@ import personalCodeToBirthday from './index' | ||
}) | ||
test('Romania', () => { | ||
expect(personalCodeToBirthday('1900101220018')).toEqual({ day: 1, month: 1, year: 1990 }) | ||
expect(personalCodeToBirthday('6010303275841')).toEqual({ day: 3, month: 3, year: 2001 }) | ||
expect(personalCodeToBirthday('2990721275847')).toEqual({ day: 21, month: 7, year: 1999 }) | ||
}) | ||
}) | ||
@@ -112,2 +118,7 @@ | ||
test('Romania', () => { | ||
expect(personalCodeToBirthday('1980521275840')).toBeNull() | ||
expect(personalCodeToBirthday('1234567890128')).toBeNull() | ||
}) | ||
test('unidentified personal code format', () => { | ||
@@ -114,0 +125,0 @@ expect(personalCodeToBirthday('abcd1234')).toBeNull() |
@@ -7,2 +7,3 @@ import denmarkParser from './parsers/denmark' | ||
import polandParser from './parsers/poland' | ||
import romaniaParser from './parsers/romania' | ||
import swedenParser from './parsers/sweden' | ||
@@ -21,2 +22,4 @@ import ukraineParser from './parsers/ukraine' | ||
return swedenParser(code) | ||
} else if (/^\d{13}$/.test(code)) { | ||
return romaniaParser(code) | ||
} else if (/^\d{6}-\d{5}$/.test(code)) { | ||
@@ -23,0 +26,0 @@ return latviaParser(code) |
@@ -38,3 +38,3 @@ import { ParsedDate } from '../types' | ||
function isValidChecksum(code: string) { | ||
function isValidChecksum(code: string): boolean { | ||
// Use the last 9 digits without checksum number | ||
@@ -41,0 +41,0 @@ const digits = code.length === 12 ? code.slice(2, 11) : code.slice(0, 9) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29153
22
504
47