Provide additional validation rules to support Vietnamese testing for Laravel.
- Laravel 8.x or later
- PHP 8.1 or later
You can install the package via composer:
composer require sphoton/validation
VietnameseRule
: The field under validation must be entirely in Vietnamese.VietnameseNumberRule
: The field under validation must be entirely in Vietnamese and number.
You can use the validation rules in your Laravel application like this:
use Sphoton\Validation\Rules\VietnameseRule;
use Sphoton\Validation\Rules\VietnameseNumberRule;
$request->validate([
'name' => ['required', 'string', new VietnameseRule],
'address' => ['required', 'string', new VietnameseNumberRule],
]);
use Sphoton\Validation\Rules\VietnameseRule;
"Nguyen Van A" // Pass
"Nguyễn Văn A" // Pass
"Nguyễn Văn A 123" // Fail
"123 Nguyễn Văn A" // Fail
"Nguyễn Văn A @" // Fail
"Nguyễn Văn A 123 @" // Fail
"Nguyễn Văn
A" // Fail
"Nguyễn Văn \nA" // Fail
use Sphoton\Validation\Rules\VietnameseNumberRule;
"Nguyen Van A" // Pass
"Nguyễn Văn A 123" // Pass
"123 Nguyễn Văn A" // Pass
"Nguyễn Văn A @" // Fail
"Nguyễn Văn A 123 @" // Fail
"Nguyễn Văn
A" // Fail
"Nguyễn Văn \nA" // Fail
Hoàng Khắc Phúc |
DNT |