PHP code example of jekk0 / laravel-iso3166-validation-rules

1. Go to this page and download the library: Download jekk0/laravel-iso3166-validation-rules library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jekk0 / laravel-iso3166-validation-rules example snippets




namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Jekk0\Laravel\Iso3166\Validation\Rules\Iso3166Alpha2;

class Test extends Controller
{
    public function index(Request $request)
    {
        // Request example: http://127.0.0.1:8000/t?country=us

        $rules = ['country' => ['


use Jekk0\Laravel\Iso3166\Validation\Rules\Iso3166Alpha2;
use Jekk0\Laravel\Iso3166\Validation\Rules\Iso3166Alpha3;
use Jekk0\Laravel\Iso3166\Validation\Rules\Iso3166Numeric;

$rules = ['countryAlpha2' => ['


...
    public function index(Request $request)
    {
        // Request example: http://127.0.0.1:8000/t?country=INVALID_INPUT

        $iso3166Alpha2Rule = (new Iso3166Alpha2())->setErrorMessage('New Custom Error Message :attribute = :input');

        $rules = ['country' => [' code is invalid: New Custom Error Message country = INVALID_INPUT