PHP code example of seeds-std / laravel-jp-validation-rules

1. Go to this page and download the library: Download seeds-std/laravel-jp-validation-rules 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/ */

    

seeds-std / laravel-jp-validation-rules example snippets


Validator::make(['name' => 'やまだたろう'], ['name' => new \SeedsStd\JpValidationRules\Hiragana()])
    ->passes(); // true

Validator::make(['name' => 'ヤマダタロウ'], ['name' => new \SeedsStd\JpValidationRules\ZenkakuKatakana()])
    ->passes(); // true

Validator::make(['name' => 'ヤマダタロウ'], ['name' => new \SeedsStd\JpValidationRules\HankakuKatakana()])
    ->passes(); // true

Validator::make(['phone_number' => '0120123456'], ['phone_number' => new \SeedsStd\JpValidationRules\PhoneNumber()])
    ->passes(); // true

Validator::make(['phone_number' => '+81120123456'], ['phone_number' => new \SeedsStd\JpValidationRules\PhoneNumber(['allow_country_code' => true])])
    ->passes(); // true

Validator::make(['postcode' => '111-2222'], ['postcode' => new \SeedsStd\JpValidationRules\Postcode()])
    ->passes(); // true



return [
    'hiragana'             => ':attributeはひらがなを指定してください。',
    'zenkaku_katakana'     => ':attributeは全角カタカナを指定してください。',
    'hankaku_katakana'     => ':attributeは半角カタカナを指定してください。',
    'jp_postcode'          => ':attributeは正しい郵便番号の形式を指定してください。',
    'jp_phone_number'      => ':attributeは正しい電話番号の形式を指定してください。',
];