rabianr / laravel-validation-japanese
Japanese validation rules for Laravel
Installs: 2 240
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >= 7.2
- illuminate/contracts: ^6|^7|^8|^9
- illuminate/support: ^6|^7|^8|^9
Requires (Dev)
- laravel/framework: ^6|^7|^8
- phpunit/phpunit: ^6|^7|^8|^9
README
Installation
composer require rabianr/laravel-validation-japanese
Configuration
Publish the config to copy the file to your own config:
php artisan vendor:publish --tag="japaneseValidation"
Usage
Allows Hiragana only
use Rabianr\Validation\Japanese\Rules\Hiragana; $validator = Validator::make($request->all(), [ 'title' => [ 'required', new Hiragana, ], ]);
Allows Hiragana, whitespace and Level 1 - 2 Kanji only
use Rabianr\Validation\Japanese\Rules\Hiragana; use Rabianr\Validation\Japanese\Rules\Kanji; $validator = Validator::make($request->all(), [ 'title' => [ 'required', new Hiragana([ ' ', new Kanji('', true) ]), ], ]);
Available Rules
Class | Constructor | Usage |
---|---|---|
Rabianr\Validation\Japanese\Rules\Hiragana | __construct($allowChars = '') | The field under validation must be Hiragana and $allowChars only. |
Rabianr\Validation\Japanese\Rules\Katakana | __construct($allowChars = '') | The field under validation must be Katakana and $allowChars only. |
Rabianr\Validation\Japanese\Rules\Kanji | __construct($allowChars = '', $JISX0208 = false) | The field under validation must be Kanji and $allowChars only. If $JISX0208 is true , Kanji must be Level 1 and 2. |
Rabianr\Validation\Japanese\Rules\KanjiJISX0208 | __construct() | If the field under validation contains Kanji, must be Level 1 and 2 only. |
Trims full-width whitespace Middleware
use Rabianr\Validation\Japanese\Middleware\TrimStrings