PHPackages                             aroon/egyptian-national-id-checker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. aroon/egyptian-national-id-checker

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

aroon/egyptian-national-id-checker
==================================

A PHP package to parse and validate Egyptian National IDs, with Laravel support.

v1.2.0(1w ago)02↓100%MITPHPPHP ^8.1CI passing

Since Mar 12Pushed 1w agoCompare

[ Source](https://github.com/aroon9002ahmed/egyptian-national-id-checker)[ Packagist](https://packagist.org/packages/aroon/egyptian-national-id-checker)[ Docs](https://github.com/aroon9002ahmed/egyptian-national-id-checker)[ RSS](/packages/aroon-egyptian-national-id-checker/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (4)Versions (3)Used By (0)

Egyptian National ID
====================

[](#egyptian-national-id)

A PHP and Laravel package to parse and validate Egyptian National IDs (14 digits).

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require aroon/egyptian-national-id-checker
```

*(Note: Ensure you are requiring the local path in your project if you haven't published it to Packagist).*

Features
--------

[](#features)

- **Sanitization**: Automatically cleans input by converting Arabic/Hindi numerals (٠-٩) to English numerals and stripping spaces or dashes.
- **Validation**: Strict validation of the 14-digit format, century, birth date, governorate code, and check digit.
- **Data extraction**: Easily extract birth date, gender, governorate, and age.

Usage in PHP
------------

[](#usage-in-php)

```
use Aroon\EgyptianNationalId\EgyptianNationalId;

// 1. Basic Parsing and Validation
$id = new EgyptianNationalId('٢٩٠-٠١٠١ ١٢٣ ٤٥٦٧');

if ($id->isValid()) {
    $id->getBirthYear();      // 1990
    $id->getGender();         // "female"
    $id->isAdult();           // true
    $id->getGovernorateName();// "Cairo"
    $data = $id->toArray();
}
```

### 🧠 Static Safe Helpers

[](#-static-safe-helpers)

Need a quick answer without crashing or handling invalid objects? Use the static safe helpers. They return `false` gracefully if the ID is malformed.

```
EgyptianNationalId::isValidId('29001011234567');   // true
EgyptianNationalId::checkIsMale('29001011234567'); // false
EgyptianNationalId::checkIsAdult('29001011234567');// true
```

### 🎲 ID Generator (For Testing/Factories)

[](#-id-generator-for-testingfactories)

Generate 100% mathematically correct National IDs matching precise criteria, great for Unit Tests:

```
// Generate a completely random valid ID
$randomId = EgyptianNationalId::generate();

// Customize generation (e.g. Female, born in 1990, from Cairo)
$specificId = EgyptianNationalId::generate([
    'gender' => 'female',
    'year' => 1990,
    'governorate' => '01' // Cairo
]);
```

### 🎛️ Data Engine (Collections and Big Data)

[](#️-data-engine-collections-and-big-data)

To analyze arrays or databases packed with thousands of IDs, use `EgyptianNationalIdEngine`:

```
use Aroon\EgyptianNationalId\EgyptianNationalIdEngine;

$dataset = ['29001011234567', '30205051234567', 'invalid_id'];

$engine = EgyptianNationalIdEngine::make($dataset);

// 1. Filter out IDs easily
$onlyMales = $engine->filter(fn($id) => $id->isMale());

// 2. Extract quick demographics & statistics
$stats = $engine->stats();
/*
{
    "total": 2,
    "males": 1,
    "females": 1,
    "adults": 2,
    "governorates": { "Cairo": 1, "Alexandria": 1 }
}
*/

// 3. Merge parsed real-world analysis into your original arrays
$users = [
    ['name' => 'Ahmed', 'national_id' => '29001011234567']
];
$analyzedUsers = $engine->mapWithAnalysis($users, 'national_id');
// Output will now contain an 'analysis' array attached to Ahmed's row with his birthday, gender, etc.
```

Usage in Laravel
----------------

[](#usage-in-laravel)

The package automatically registers a ServiceProvider for Laravel. It provides a new validation rule called `national_id`, which you can use directly in your Form Requests or inline validation.

```
use Illuminate\Http\Request;

public function store(Request $request)
{
    $request->validate([
        'national_id_field' => ['required', 'string', 'national_id'],
    ]);

    // Or the string syntax
    // 'national_id_field' => 'required|string|national_id',

    // ...
}
```

Or you can use the built-in Rule object:

```
use Aroon\EgyptianNationalId\Rules\NationalIdRule;

public function store(Request $request)
{
    $request->validate([
        'national_id_field' => ['required', new NationalIdRule()],
    ]);
}
```

Testing
-------

[](#testing)

Run the included PHPUnit tests with:

```
composer test
# or
./vendor/bin/phpunit
```

License
-------

[](#license)

MIT License.

Note
----

[](#note)

This package is based on the algorithm and logic from [mahmoudEbeid2/egyptian-national-id](https://github.com/mahmoudEbeid2/egyptian-national-id).

###  Health Score

39

—

LowBetter than 87% of packages

Maintenance98

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

11d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed5c726d97ad2603f18cb934794a4de9c0e7fd0c1623bf50700c9192e35a1165?d=identicon)[ahmedsaad](/maintainers/ahmedsaad)

---

Top Contributors

[![aroon9002ahmed](https://avatars.githubusercontent.com/u/7735634?v=4)](https://github.com/aroon9002ahmed "aroon9002ahmed (8 commits)")

---

Tags

phplaravelvalidationnational idEgypt

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aroon-egyptian-national-id-checker/health.svg)

```
[![Health](https://phpackages.com/badges/aroon-egyptian-national-id-checker/health.svg)](https://phpackages.com/packages/aroon-egyptian-national-id-checker)
```

###  Alternatives

[yorcreative/laravel-argonaut-dto

Argonaut is a lightweight Data Transfer Object (DTO) package for Laravel that supports nested casting, recursive serialization, and validation out of the box. Ideal for service layers, APIs, and clean architecture workflows.

1042.4k1](/packages/yorcreative-laravel-argonaut-dto)[reducktion/socrates

A package to validate, and extract citizen information from, national identification numbers.

488.4k](/packages/reducktion-socrates)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
