brokeyourbike/country-validation-laravel

Laravel country validation rules

Fund package maintenance!
brokeyourbike
Open Collective

Installs: 548

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

pkg:composer/brokeyourbike/country-validation-laravel

0.1.2 2023-05-14 22:31 UTC

This package is auto-updated.

Last update: 2025-10-20 16:32:31 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