seeds-std/laravel-jp-validation-rules

This package is abandoned and no longer maintained. No replacement package was suggested.

Validate Jp rules

0.1.1 2020-11-12 03:10 UTC

This package is not auto-updated.

Last update: 2021-12-09 08:20:32 UTC


README

Build Status codecov Scrutinizer Code Quality

Installation

composer require seeds-std/laravel-jp-validation-rules

Usage

Hiragana

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

ZenkakuKatakana

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

HankakuKatakana

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

PhoneNumber

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

Postcode

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

Translation

Translate validation messages with resources/lang/ja/validation.php

<?php

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