PHP code example of phattarachai / thai-id-card-validation
1. Go to this page and download the library: Download phattarachai/thai-id-card-validation library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phattarachai / thai-id-card-validation example snippets
use Phattarachai\ThaiIdCardValidation\ThaiIdCardRule;
// ใน controller
$this->validate($request, [
'email' => '
use Phattarachai\ThaiIdCardValidation\ThaiIdCardRule as Rule;
class ThaiIdCardRule extends Rule
{
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return 'รหัสบัตรประชาชนไม่ถูกต้อง';
}
}
use Phattarachai\ThaiIdCardValidation\ThaiIdCard;
$result = (new ThaiIdCard)->validate('1085217077105');
// true
$result = (new ThaiIdCard)->validate('1234567890123');
// false