brokeyourbike/country-validation-laravel

Laravel country validation rules

0.1.2 2023-05-14 22:31 UTC

This package is auto-updated.

Last update: 2024-11-20 14:43:33 UTC


README

Latest Stable Version Total Downloads Maintainability Test Coverage

Laravel country validation rules

Installation

composer require brokeyourbike/country-validation-laravel

Usage

use Illuminate\Foundation\Http\FormRequest;
use BrokeYourBike\CountryValidation\IsValidCountryCodeAlpha2;
use BrokeYourBike\CountryValidation\IsValidCountryCodeAlpha3;

class ExampleRequest extends FormRequest
{
    public function rules()
    {
        return [
            'country_alpha2' => [
                'required',
                'string',
                'size:2',
                new IsValidCountryCodeAlpha2(),
            ],
            'country_alpha3' => [
                'required',
                'string',
                'size:3',
                new IsValidCountryCodeAlpha3(),
            ],
        ];
    }
}

Authors

License

Mozilla Public License v2.0