sphoton/validation

Validation for Laravel Framework

v1.0.5 2024-03-21 07:50 UTC

This package is not auto-updated.

Last update: 2024-11-15 05:59:00 UTC


README

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