Skip to content

This library parses Egyptian national ID and extracts data from it.

License

Notifications You must be signed in to change notification settings

ahmedsaleh020/parse-national-id

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Parse National ID

Description

This library parses Egyptian national ID and extracts data from it.

Installation

  • You can install the library from npm using the following command:

    npm install parse-national-id

    then import it in your project:

    import { parseNationalId } from "parse-national-id";
  • You can also import the library directly from the CDN:

    import { parseNationalId } from "https://unpkg.com/parse-national-id";

Usage

The library exports a function called parseNationalId that takes Two parameters (the ID) as a string and A default Parameter for the language as a string and returns the parse result in an object in the case of ID is valid, otherwise returns null.

example :

import { parseNationalId } from "parse-national-id";

const result = parseNationalId("30207072500379");

console.log(result);
// {
//   birthDay: '07',
//   birthMonth: '07',
//   birthYear: '2002',
//   birthDate: '07/07/2002',
//   birthOrder: '3',
//   gender: 'Male',
//   birthCity: 'Asyut'
// }
import { parseNationalId } from "parse-national-id";

const result = parseNationalId("30207072500379", "ar");

console.log(result);
// {
//   birthDay: '07',
//   birthMonth: '07',
//   birthYear: '2002',
//   birthDate: '07/07/2002',
//   birthOrder: '3',
//   gender: 'ذكر',
//   birthCity: 'أسيوط'
// }

In the case of using an invalid ID, the function will return null

for example :

import { parseNationalId } from "parse-national-id";

const result = parseNationalId("302070725003");

console.log(result);
// null

Contributing

Contributions are welcome! Feel free to submit bug reports, feature requests, or pull requests to help improve this project.

License

MIT License © Ahmed Saleh

About

This library parses Egyptian national ID and extracts data from it.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published