sphoton / validation
Validation for Laravel Framework
Installs: 2 399
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- illuminate/support: ^10.0||^11.0
Requires (Dev)
- illuminate/translation: ^10.0||^11.0
- illuminate/validation: ^10.0||^11.0
- laravel/pint: ^1.0
- pestphp/pest: 3.x-dev
README
About
Provide additional validation rules to support Vietnamese testing for Laravel.
Condition
- Laravel 8.x or later
- PHP 8.1 or later
Installation
You can install the package via composer:
composer require sphoton/validation
Available Rules
VietnameseRule
: The field under validation must be entirely in Vietnamese.VietnameseNumberRule
: The field under validation must be entirely in Vietnamese and number.
Usage
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