PHP code example of worawitj / validation

1. Go to this page and download the library: Download worawitj/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/ */

    

worawitj / validation example snippets


use Worawitj\Validation\ThaiIdCardRule;

// ใน controller
$this->validate($request, [
    'email' => '

use Worawitj\Validation\ThaiIdCardRule;

// ใน controller
$validator = Validator::make($request_data, ['id_card' => '

use Worawitj\Validation\ThaiIdCardRule as Rule;


class NewThaiIdCardRule extends Rule
{
    /**
     * Get the validation error message.
     *
     * @return string
     */
     public function message()
    {

        return $this->message?:"Please Check Your IdCard";
    }
}


use WorawitjIdcardValidate\ThaiIdCardValidation\NewThaiIdCardRule;

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

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