Looking to hire Laravel developers? Try LaraJobs

country-validation-laravel maintained by brokeyourbike

Description
Laravel country validation rules
Author
Last update
2023/05/20 13:35 (dev-release-v0.1.3)
License
Links
Downloads
548

Comments
comments powered by Disqus

country-validation-laravel

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