PHPackages                             elbgoods/laravel-country-rule - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. elbgoods/laravel-country-rule

AbandonedArchivedLibrary[Validation &amp; Sanitization](/categories/validation)

elbgoods/laravel-country-rule
=============================

Laravel validation rules for ISO-3166 country formats.

0.4.0(5y ago)74.9k11MITPHPPHP ^7.4 || ^8.0

Since Feb 10Pushed 5y ago5 watchersCompare

[ Source](https://github.com/elbgoods/laravel-country-rule)[ Packagist](https://packagist.org/packages/elbgoods/laravel-country-rule)[ Docs](https://github.com/elbgoods/laravel-country-rule)[ RSS](/packages/elbgoods-laravel-country-rule/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (5)Versions (6)Used By (1)

Laravel Country Validation Rules
================================

[](#laravel-country-validation-rules)

[![Latest Version](https://camo.githubusercontent.com/740b00eaee181ff27907dfd362d8933f3ee1991942802b85f4fc63e42f3f1b77/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656c62676f6f64732f6c61726176656c2d636f756e7472792d72756c652e7376673f6c6162656c3d52656c65617365267374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/elbgoods/laravel-country-rule)[![MIT License](https://camo.githubusercontent.com/10cd27dec6ca41107694b2c01ba944e8171653a76687ce34f835c28843ebc232/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f656c62676f6f64732f6c61726176656c2d636f756e7472792d72756c652e7376673f6c6162656c3d4c6963656e736526636f6c6f723d626c7565267374796c653d666f722d7468652d6261646765)](https://github.com/elbgoods/laravel-country-rule/blob/master/LICENSE)[![Offset Earth](https://camo.githubusercontent.com/adde0313ccccfe3a49df6bd5075d1391cd7ee9e58c373c83dc9eff84e87ce181/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54726565776172652d2546302539462538432542332d677265656e3f7374796c653d666f722d7468652d62616467652663616368655365636f6e64733d363030)](https://plant.treeware.earth/elbgoods/laravel-country-rule)

[![GitHub Workflow Status](https://camo.githubusercontent.com/822f0d9d001ed855ed2fd2735b786774199fb2f728addd45c26a3707dba1fbc0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f656c62676f6f64732f6c61726176656c2d636f756e7472792d72756c652f72756e2d74657374733f6c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/elbgoods/laravel-country-rule/actions?query=workflow%3Arun-tests)[![StyleCI](https://camo.githubusercontent.com/d6307bf7b99a376949b008354048b8f06b24ee5aa779df8f183ba43ee4b66c07/68747470733a2f2f7374796c6563692e696f2f7265706f732f3233393534343134322f736869656c64)](https://styleci.io/repos/239544142)[![Total Downloads](https://camo.githubusercontent.com/2741a318bd5eba8119adf822a47116986019c5da7a526d49b5d963b7b16cecf0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656c62676f6f64732f6c61726176656c2d636f756e7472792d72756c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elbgoods/laravel-country-rule)

This package provides multiple validation rules to validate countries according to [ISO-3166](https://wikipedia.org/wiki/ISO_3166).

Installation
------------

[](#installation)

At first you have to add this package to your `composer.json`:

```
composer require elbgoods/laravel-country-rule
```

After this you can publish the package translation files to adjust the error messages:

```
php artisan vendor:publish --provider="Elbgoods\CountryRule\CountryRuleServiceProvider" --tag=lang
```

Usage
-----

[](#usage)

### General

[](#general)

This package provides a basic `CountryRule` which you can use. All more specific rules only extend this rule with a predefined `format`.

```
use Elbgoods\CountryRule\Rules\CountryRule;
use League\ISO3166\ISO3166;

$rule = new CountryRule(ISO3166::KEY_ALPHA2);
```

By default the rule requires a value - if you want to accept `null` values you can use the `nullable()` method or set the `$required` parameter to `false`.

```
use Elbgoods\CountryRule\Rules\CountryRule;
use League\ISO3166\ISO3166;

$rule = new CountryRule(ISO3166::KEY_ALPHA2, false);
$rule->nullable();
```

### Alpha2

[](#alpha2)

```
use Elbgoods\CountryRule\Rules\CountryAlpha2Rule;

$rule = new CountryAlpha2Rule();
```

### Alpha3

[](#alpha3)

```
use Elbgoods\CountryRule\Rules\CountryAlpha3Rule;

$rule = new CountryAlpha3Rule();
```

### Name

[](#name)

```
use Elbgoods\CountryRule\Rules\CountryNameRule;

$rule = new CountryNameRule();
```

### Numeric

[](#numeric)

```
use Elbgoods\CountryRule\Rules\CountryNumericRule;

$rule = new CountryNumericRule();
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Versioning
----------

[](#versioning)

This package follows [semantic versioning](https://semver.org/).

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

Please see [SECURITY](SECURITY.md) for details.

Credits
-------

[](#credits)

- [Tom Witkowski](https://github.com/Gummibeer)
- [All Contributors](https://github.com/elbgoods/laravel-country-rule/graphs/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

Treeware
--------

[](#treeware)

You're free to use this package, but if it makes it to your production environment we would highly appreciate you buying or planting the world a tree.

It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to [plant trees](https://www.bbc.co.uk/news/science-environment-48870920). If you contribute to my forest you’ll be creating employment for local families and restoring wildlife habitats.

You can buy trees at [offset.earth/treeware](https://plant.treeware.earth/elbgoods/laravel-country-rule)

Read more about Treeware at

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~100 days

Total

5

Last Release

1882d ago

PHP version history (2 changes)0.1.0PHP ^7.4

0.4.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/eb5d60f7dd33ef3680490f11b3cd461b0c7a5dcddfe69d57fb1f6a3406be4570?d=identicon)[Gummibeer](/maintainers/Gummibeer)

![](https://www.gravatar.com/avatar/33a11c820ca1801a2b0cc065786385f9a1746ae02d1a120102ea7fc7f545eeb7?d=identicon)[Elbgoods](/maintainers/Elbgoods)

---

Top Contributors

[![Gummibeer](https://avatars.githubusercontent.com/u/6187884?v=4)](https://github.com/Gummibeer "Gummibeer (29 commits)")[![jamesmills](https://avatars.githubusercontent.com/u/557096?v=4)](https://github.com/jamesmills "jamesmills (1 commits)")

---

Tags

countryiso3166laravellaravel-country-ruletreewarevalidate-countriesvalidationvalidation-ruleslaravelvalidationcountryIso3166

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/elbgoods-laravel-country-rule/health.svg)

```
[![Health](https://phpackages.com/badges/elbgoods-laravel-country-rule/health.svg)](https://phpackages.com/packages/elbgoods-laravel-country-rule)
```

###  Alternatives

[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M107](/packages/propaganistas-laravel-phone)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)[galahad/laravel-addressing

Laravel package providing addressing functionality

70316.6k](/packages/galahad-laravel-addressing)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
