PHPackages                             phattarachai/thai-id-card-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. phattarachai/thai-id-card-validation

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

phattarachai/thai-id-card-validation
====================================

A Laravel and PHP package for validating Thai ID Card

1.0(5y ago)33.1k↓50%4MITPHPPHP ^7.3|^8.0

Since Mar 5Pushed 5y ago1 watchersCompare

[ Source](https://github.com/phattarachai/thai-id-card-validation)[ Packagist](https://packagist.org/packages/phattarachai/thai-id-card-validation)[ RSS](/packages/phattarachai-thai-id-card-validation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

[![test](https://github.com/phattarachai/thai-id-card-validation/actions/workflows/php.yml/badge.svg)](https://github.com/phattarachai/thai-id-card-validation/actions/workflows/php.yml/badge.svg)[![Packagist](https://camo.githubusercontent.com/64fa95f540e7667b14c2b67499500d25e7dca7766e81b6c15535b29c78880757/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068617474617261636861692f746861692d69642d636172642d76616c69646174696f6e2e737667)](https://github.com/phattarachai/thai-id-card-validation/releases)

 🔒 Thai ID Card Laravel Validation
========================================================================

[](#--thai-id-card-laravel-validation)

แพคเกจนี้เพิ่ม Validation Rule สำหรับตรวจสอบความถูกต้องรหัสบัตรประชาชน สามารถใช้ได้ทั้งในใน Laravel และ PHP Project.

 ติดตั้ง
==============================================

[](#-ติดตั้ง)

```
composer require phattarachai/thai-id-card-validation

```

 การใช้งาน
=========================================

[](#-การใช้งาน)

เรียกใช้ class `ThaiIdCardRule` ใน field ที่ต้องการ validate

```
use Phattarachai\ThaiIdCardValidation\ThaiIdCardRule;

// ใน controller
$this->validate($request, [
    'email' => 'required',
    'id_card_no' => new ThaiIdCardRule,
    // ...
]);
```

หากต้องการตัวอย่างเลขรหัสบัตรประชาชนเพื่อใช้ทดสอบระบบ สามารถไปได้ที่ [เครื่องมือสุ่มรหัสบัตรประชาชน](https://phattarachai.dev/tools/thai-id-card-generator)

 Validation Message
==================================================

[](#-validation-message)

ถ้า validate ไม่ผ่านจะแสดงข้อความ `รหัสบัตรประชาชนไม่ถูกต้อง` เป็นค่าเริ่มต้ม ถ้าต้องการแก้ไข message สามารถ override class เพื่อแก้ message ได้

```
use Phattarachai\ThaiIdCardValidation\ThaiIdCardRule as Rule;

class ThaiIdCardRule extends Rule
{
    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return 'รหัสบัตรประชาชนไม่ถูกต้อง';
    }
}
```

การใช้งานใน PHP (นอก Laravel Project)
=====================================

[](#การใช้งานใน-php-นอก-laravel-project)

ถ้าต้องการตรวจสอบรหัสบัตรประชาชนใน PHP หรือ Framework อื่น ๆ ที่ไม่ใช่ Laravel สามารถทำได้ผ่าน class `ThaiIdCard`

```
use Phattarachai\ThaiIdCardValidation\ThaiIdCard;

$result = (new ThaiIdCard)->validate('1085217077105');
// true

$result = (new ThaiIdCard)->validate('1234567890123');
// false
```

สนับสนุน
--------

[](#สนับสนุน)

[ ![Sticker Line by phattarachai.dev](https://camo.githubusercontent.com/0c27dbf6d20a0b90244d52774bef1e7492929c3a6b8851c5e45d99a465b3754f/68747470733a2f2f6d652e7068617474617261636861692e6465762f77702d636f6e74656e742f75706c6f6164732f323032312f30332f42616e6e65722e706e67)](https://store.line.me/stickershop/author/2080520/en)[phattarachai.dev](https://phattarachai.dev) เขียน blog และ opensource library ที่เกี่ยวกับ Laravel และ PHP ให้นักพัฒนาชาวไทยได้ใช้ สามารถสนับสนุนผมได้ผ่านทาง LINE Sticker ที่ผมได้ทำขึ้นได้เลยครับที่ [LINE Store](https://store.line.me/stickershop/author/2080520/en).

Credit
------

[](#credit)

[ติดตามผมได้ที่ Twitter](https://twitter.com/phatchai)

[Buy me a Coffee](https://ko-fi.com/phattarachai#checkoutModal)

License
-------

[](#license)

The MIT License (MIT)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

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

Unknown

Total

1

Last Release

1895d ago

### Community

Maintainers

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

---

Top Contributors

[![phattarachai](https://avatars.githubusercontent.com/u/2162876?v=4)](https://github.com/phattarachai "phattarachai (9 commits)")

---

Tags

laravelphpthaivalidation

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/phattarachai-thai-id-card-validation/health.svg)](https://phpackages.com/packages/phattarachai-thai-id-card-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)
