Skip to content

Latest commit

 

History

History
80 lines (69 loc) · 3.06 KB

README.md

File metadata and controls

80 lines (69 loc) · 3.06 KB

Laravel Logo

Total Downloads Latest Stable Version License

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

Contributors

Hoàng
Hoàng Khắc Phúc
DNT/
DNT