PHPackages                             farzai/thai-citizen-id-validation - 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. farzai/thai-citizen-id-validation

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

farzai/thai-citizen-id-validation
=================================

Thai citizen id validation

1.3.0(1y ago)118082[5 PRs](https://github.com/farzai/thai-citizen-id-validation-php/pulls)MITPHPPHP ^8.1CI passing

Since May 24Pushed 1mo agoCompare

[ Source](https://github.com/farzai/thai-citizen-id-validation-php)[ Packagist](https://packagist.org/packages/farzai/thai-citizen-id-validation)[ Docs](https://github.com/farzai/thai-citizen-id-validation-php)[ GitHub Sponsors](https://github.com/parsilver)[ RSS](/packages/farzai-thai-citizen-id-validation/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (12)Versions (12)Used By (0)

Thai Citizen ID Validator PHP
=============================

[](#thai-citizen-id-validator-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fe5f6ddaa612e3d79d634348be81be0956d8679eff4a67f4eca60a81eeea2f4d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6661727a61692f746861692d636974697a656e2d69642d76616c69646174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/farzai/thai-citizen-id-validation)[![Tests](https://camo.githubusercontent.com/4d4c878d15ab0027a690a21ce3c5e8c2ba72d586872fc5b2483e792934db006b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6661727a61692f746861692d636974697a656e2d69642d76616c69646174696f6e2d7068702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/farzai/thai-citizen-id-validation-php/actions/workflows/run-tests.yml)[![codecov](https://camo.githubusercontent.com/60a7d97f7ecd3e3427ca3efdd21b75386cb47ce8927f1a044c937ddd9a6a7d81/68747470733a2f2f636f6465636f762e696f2f67682f6661727a61692f746861692d636974697a656e2d69642d76616c69646174696f6e2d7068702f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/farzai/thai-citizen-id-validation-php)[![Total Downloads](https://camo.githubusercontent.com/fd06066033f63221cb47f9bc591a08bd4f58e46a475f97ee41ea13232fc24fd0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6661727a61692f746861692d636974697a656e2d69642d76616c69646174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/farzai/thai-citizen-id-validation)

Thai Citizen ID validator is a easy-to-use PHP library designed to help validate Thai National Identification Card numbers

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

[](#installation)

You can install the package via composer:

```
composer require farzai/thai-citizen-id-validation
```

Usage for validation
--------------------

[](#usage-for-validation)

Example usage for validating Thai Citizen ID

```
use Farzai\ThaiIdValidation\Validator;
use Farzai\ThaiIdValidation\Exceptions\InvalidThaiCitizenIdException;

$validator = new Validator();

try {
    $validator->validate('1410100100000');
} catch (InvalidThaiCitizenIdException $e) {
    // Handle invalid citizen id
}
```

Usage for generating
--------------------

[](#usage-for-generating)

Sometimes you need to generate a random Thai Citizen ID for testing purpose. This library can help you with that.

```
use Farzai\ThaiIdValidation\Generator;

$generator = new Generator();

// Optional
$generator
    ->personType(1) // ประเภทบุคคล
    ->provinceOfBirth('10') // เลขจังหวัดที่เกิด
    ->districtOfBirth('10'); // เลขอำเภอที่เกิด

// Generate
$idCard = $generator->generate();

echo (string)$idCard; // 1410100100000

echo $idCard->getId(); // 1410100100000
echo $idCard->getType(); // 1 digit
echo $idCard->getProvinceOfBirth(); // 2 digit
echo $idCard->getDistrictOfBirth(); // 2 digit
echo $idCard->getVolume(); // 5 digit
echo $idCard->getNumber(); // 2 digit
echo $idCard->getCheckDigit(); // 1 digit
```

Usage with Laravel
------------------

[](#usage-with-laravel)

You can use the `IdCard` rule to validate Thai Citizen ID in Laravel.

```
use Farzai\ThaiIdValidation\Laravel\Rules\IdCard;

$request->validate([
    'id_card' => ['required', new IdCard],
]);
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [parsilver](https://github.com/parsilver)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance67

Regular maintenance activity

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 59.7% 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 ~102 days

Recently: every ~128 days

Total

6

Last Release

578d ago

PHP version history (2 changes)1.0.0PHP ^8.1

1.2.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4928451?v=4)[parsilver](/maintainers/parsilver)[@parsilver](https://github.com/parsilver)

---

Top Contributors

[![parsilver](https://avatars.githubusercontent.com/u/4928451?v=4)](https://github.com/parsilver "parsilver (46 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (19 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (12 commits)")

---

Tags

citizenid-cardid-card-generatorthaifarzaithai-idthai-citizen

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/farzai-thai-citizen-id-validation/health.svg)

```
[![Health](https://phpackages.com/badges/farzai-thai-citizen-id-validation/health.svg)](https://phpackages.com/packages/farzai-thai-citizen-id-validation)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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