Download the PHP package phattarachai/thai-id-card-validation without Composer

On this page you can find all versions of the php package phattarachai/thai-id-card-validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package thai-id-card-validation

Thai ID Card Validation

Latest Version on Packagist Tests Code Style PHP Version Laravel Version Total Downloads

Validation rule สำหรับตรวจเลขบัตรประชาชนไทย 13 หลัก ใช้ได้ทั้งใน Laravel และ PHP ทั่วไป

English

ติดตั้ง

ต้องใช้ PHP 8.3 ขึ้นไป และ Laravel 12 หรือ 13

ใช้ใน Laravel

แนะนำให้ใส่ digits:13 คู่กันเสมอ ตัว rule เองไม่ผ่านค่าที่ไม่ใช่ตัวเลข 13 หลักอยู่แล้ว แต่ digits:13 จะบอกผู้ใช้ได้ตรงกว่าว่าพิมพ์ไม่ครบหรือเกิน ส่วน bail ทำให้ขึ้นแค่ข้อความเดียว

rule นี้ตรวจแค่หลักสุดท้าย (check digit) ว่าคำนวณตรงกับ 12 หลักแรก ไม่ได้ตรวจว่ามีคนที่ถือเลขนี้อยู่จริง เลขที่สุ่มขึ้นมาแต่ check digit ถูกก็ผ่าน ถ้าต้องการยืนยันตัวตนต้องตรวจกับแหล่งข้อมูลอื่น

ต้องการเลขไว้ทดสอบระบบ ใช้ เครื่องมือสุ่มเลขบัตรประชาชน ได้

ข้อความเมื่อไม่ผ่าน

ค่าเริ่มต้นคือ รหัสบัตรประชาชนไม่ถูกต้อง เปลี่ยนได้สามทาง เรียงจากที่ rule เลือกใช้ก่อน

  1. ส่งข้อความหรือ lang key เข้า constructor ใช้กับ field นั้น field เดียว

  2. เพิ่ม key thai_id_card ใน lang/{locale}/validation.php ของแอป ใช้กับทุก field และแปลตาม locale ได้

  3. ถ้าไม่มีทั้งสองอย่าง ใช้ข้อความภาษาไทยค่าเริ่มต้น

ทุกแบบใช้ :attribute ได้ และ $messages ของ validator ก็ยังใช้ได้ตามปกติ โดยใช้ชื่อ class เป็น key เช่น 'id_card.'.ThaiIdCardRule::class => '...'

เลขที่มีขีดหรือเว้นวรรค

rule รับเฉพาะตัวเลข 13 หลักติดกัน เลขแบบ 1-7370-63686-01-3 หรือ 1 7370 63686 01 3 จะไม่ผ่าน ถ้าฟอร์มยอมให้พิมพ์แบบนั้น ให้ตัดขีดและช่องว่างออกก่อน validate ค่าที่บันทึกลงฐานข้อมูลจะได้เป็นแบบเดียวกันด้วย

ใช้ใน PHP ทั่วไป

รับ string หรือ int ค่าอื่นทั้งหมด (null, array, object, float) คืน false

อัปเกรดจาก 1.x

English

A validation rule for 13-digit Thai national ID card numbers, for Laravel and plain PHP. Requires PHP 8.3+ and Laravel 12 or 13.

Message. The rule uses, in order: a message or lang key passed to the constructor (new ThaiIdCardRule(':attribute is invalid')), the app's validation.thai_id_card lang key, then the Thai default รหัสบัตรประชาชนไม่ถูกต้อง. :attribute is replaced in all of them.

Outside Laravel, (new ThaiIdCard)->validate($value) returns a bool. It accepts a string or an int; anything else returns false.

Upgrading from 1.x. The rule now implements ValidationRule, so passes() is gone. A subclass that overrides message() must declare : string. Input containing letters, which 1.0 could pass, now fails.

ผู้พัฒนา

พัฒนาและดูแลโดย บริษัท ภัทรชัย อาร์ทิซาน จำกัด (Phattarachai Artisan) บริษัทที่ปรึกษาและพัฒนาเว็บ ที่เรียนรู้และแบ่งปันกับชุมชน Laravel แพ็กเกจนี้แบ่งปันให้ชุมชนนำไปใช้และต่อยอดได้อย่างอิสระ

ดูแพ็กเกจอื่นของเราได้ที่ phattarachai.dev/open-source และติดต่อเราได้ที่ phattarachai.dev

License

The MIT License (MIT). See LICENSE.


All versions of thai-id-card-validation with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/support Version ^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package phattarachai/thai-id-card-validation contains the following files

Loading the files please wait ...