Package Data | |
---|---|
Maintainer Username: | Jekk0 |
Package Create Date: | 2019-05-25 |
Package Last Update: | 2024-11-01 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-15 15:24:16 |
Package Statistics | |
---|---|
Total Downloads: | 47,864 |
Monthly Downloads: | 1,803 |
Daily Downloads: | 83 |
Total Stars: | 1 |
Total Watchers: | 0 |
Total Forks: | 2 |
Total Open Issues: | 0 |
Install the latest version with
$ composer require jekk0/laravel-iso3166-validation-rules
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Jekk0\laravel\Iso3166\Validation\Rules\Iso3166Alpha2;
class Test extends Controller
{
public function index(Request $request)
{
$rules = ['country' => ['required', new Iso3166Alpha2()]]; // ISO3166-1 Alpha2 validation rule
$this->validate($request, $rules);
// etc ...
}
}
<?php
use Jekk0\laravel\Iso3166\Validation\Rules\Iso3166Alpha2;
use Jekk0\laravel\Iso3166\Validation\Rules\Iso3166Alpha3;
use Jekk0\laravel\Iso3166\Validation\Rules\Iso3166Numeric;
$rules = ['countryAlpha2' => ['required', new Iso3166Alpha2()]]; // ISO3166-1 Alpha2 validation rule
$rules = ['countryAlpha3' => ['required', new Iso3166Alpha3()]]; // ISO3166-1 Alpha3 validation rule
$rules = ['countryNumeric' => ['required', new Iso3166Numeric()]]; // ISO3166-1 Numeric validation rule
<?php
...
public function index(Request $request)
{
$iso3166Alpha2Rule = (new Iso3166Alpha2())->setErrorMessage('New Custom Error Message :attribute = :input');
$rules = ['country' => ['required', $iso3166Alpha2Rule]]; // ISO3166-1 Alpha2 validation rule
$this->validate($request, $rules);
// etc ...
}
// Output
// New Custom Error Message country = ZZZ
Laravel/Lument automatically parse error message and replace: