PHPackages                             rocketfellows/iso-standard-3166-validation - 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. rocketfellows/iso-standard-3166-validation

ActiveLibrary

rocketfellows/iso-standard-3166-validation
==========================================

v1.0.0(3y ago)0196↓100%[1 issues](https://github.com/rocketfellows/iso-standard-3166-validation/issues)1MITPHPPHP &gt;=7.4

Since Jan 11Pushed 3y agoCompare

[ Source](https://github.com/rocketfellows/iso-standard-3166-validation)[ Packagist](https://packagist.org/packages/rocketfellows/iso-standard-3166-validation)[ RSS](/packages/rocketfellows-iso-standard-3166-validation/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (1)

Country code validators
=======================

[](#country-code-validators)

[![Code Coverage Badge](./badge.svg)](./badge.svg)

This component consist of several country code validators. Validated country code formats:

- alpha2
- alpha3
- full name
- numeric code

It also can validate batch country code values and returns array of invalid given codes (or full name).

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

[](#installation)

```
composer require rocketfellows/iso-standard-3166-validation
```

Validate alpha2 code usage example
----------------------------------

[](#validate-alpha2-code-usage-example)

Note: validation case-insensitive.

### Static usage

[](#static-usage)

Valid alpha2 country code:

```
Alpha2::create()->isValid('DE');
Alpha2::create()->isValid('de');
Alpha2::create()->isValid('De');
Alpha2::create()->isValid('dE');
```

Returns:

```
true
true
true
true
```

Invalid alpha2 country code:

```
Alpha2::create()->isValid('OO');
```

Returns:

```
false
```

### New instance creation usage

[](#new-instance-creation-usage)

Valid alpha2 country code:

```
$validator = new Alpha2();
$validator->isValid('DE')
```

Returns:

```
true
```

Invalid alpha2 country code:

```
$validator = new Alpha2();
$validator->isValid('OO')
```

Returns:

```
false
```

Validate alpha3 code usage example
----------------------------------

[](#validate-alpha3-code-usage-example)

Note: validation case-insensitive.

### Static usage

[](#static-usage-1)

Valid alpha3 country code:

```
Alpha3::create()->isValid('GBR')
Alpha3::create()->isValid('gbr')
Alpha3::create()->isValid('Gbr')
```

Returns:

```
true
true
true
```

Invalid alpha3 country code:

```
Alpha3::create()->isValid('FOO');
```

Returns:

```
false
```

### New instance creation usage

[](#new-instance-creation-usage-1)

Valid alpha3 country code:

```
$validator = new Alpha3();
$validator->isValid('GBR')
```

Returns:

```
true
```

Invalid alpha3 country code:

```
$validator = new Alpha3();
$validator->isValid('FOO')
```

Returns:

```
false
```

Validate numeric code usage example
-----------------------------------

[](#validate-numeric-code-usage-example)

### Static usage

[](#static-usage-2)

Valid country numeric code:

```
NumericCode::create()->isValid('646');
```

Returns:

```
true
```

Invalid country numeric code:

```
NumericCode::create()->isValid('000');
```

Returns:

```
false
```

### New instance creation usage

[](#new-instance-creation-usage-2)

Valid country numeric code:

```
$validator = new NumericCode();
$validator->isValid('646')
```

Returns:

```
true
```

Invalid country numeric code:

```
$validator = new NumericCode();
$validator->isValid('000')
```

Returns:

```
false
```

Validate country name usage example
-----------------------------------

[](#validate-country-name-usage-example)

Note: validation case-sensitive.

### Static usage

[](#static-usage-3)

Valid country name:

```
Name::create()->isValid('Northern Mariana Islands');
```

Returns:

```
true
```

Invalid country name:

```
Name::create()->isValid('foo');
```

Returns:

```
false
```

### New instance creation usage

[](#new-instance-creation-usage-3)

Valid country name:

```
$validator = new Name();
$validator->isValid('Northern Mariana Islands')
```

Returns:

```
true
```

Invalid country name:

```
$validator = new Name();
$validator->isValid('foo')
```

Returns:

```
false
```

Validate alpha2 batch codes usage example
-----------------------------------------

[](#validate-alpha2-batch-codes-usage-example)

Note: validation case-insensitive.

### Static usage

[](#static-usage-4)

Validation:

```
Alpha2Batch::create()->getInvalidValues(['DE', 'HH', 'BY', 'ZZ', 'GB',]);
```

Returns:

```
['HH', 'ZZ']
```

### New instance creation usage

[](#new-instance-creation-usage-4)

Validation:

```
$validator = new Alpha2Batch(Alpha2::create()); // possible inject other Alpha2 validator implementation
$validator->getInvalidValues(['DE', 'HH', 'BY', 'ZZ', 'GB',]);
```

Returns:

```
['HH', 'ZZ']
```

Validate alpha3 batch codes usage example
-----------------------------------------

[](#validate-alpha3-batch-codes-usage-example)

Note: validation case-insensitive.

### Static usage

[](#static-usage-5)

Validation:

```
Alpha3Batch::create()->getInvalidValues(['GBR', 'HH', 'RUS', 'ZZ', 'DEU',]);
```

Returns:

```
['HH', 'ZZ']
```

### New instance creation usage

[](#new-instance-creation-usage-5)

Validation:

```
$validator = new Alpha3Batch(Alpha3::create()); // possible inject other Alpha3 validator implementation
$validator->getInvalidValues(['GBR', 'HH', 'RUS', 'ZZ', 'DEU',]);
```

Returns:

```
['HH', 'ZZ']
```

Validate numeric codes batch usage example
------------------------------------------

[](#validate-numeric-codes-batch-usage-example)

### Static usage

[](#static-usage-6)

Validation:

```
NumericCodeBatch::create()->getInvalidValues(['882', '000', '674', '111', '678',]);
```

Returns:

```
['000', '111']
```

### New instance creation usage

[](#new-instance-creation-usage-6)

Validation:

```
$validator = new NumericCodeBatch(NumericCode::create()); // possible inject other NumericCode validator implementation
$validator->getInvalidValues(['882', '000', '674', '111', '678',]);
```

Returns:

```
['000', '111']
```

Validate country names batch usage example
------------------------------------------

[](#validate-country-names-batch-usage-example)

Note: validation case-sensitive.

### Static usage

[](#static-usage-7)

Validation:

```
NameBatch::create()->getInvalidValues(['Samoa', 'foo', 'Sao Tome and Principe', 'bar', 'Saudi Arabia',]);
```

Returns:

```
['foo', 'bar']
```

### New instance creation usage

[](#new-instance-creation-usage-7)

Validation:

```
$validator = new NameBatch(Name::create()); // possible inject other Name validator implementation
$validator->getInvalidValues(['Samoa', 'foo', 'Sao Tome and Principe', 'bar', 'Saudi Arabia',]);
```

Returns:

```
['foo', 'bar']
```

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

[](#contributing)

Welcome to pull requests. If there is a major changes, first please open an issue for discussion.

Please make sure to update tests as appropriate.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.3% 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

Unknown

Total

1

Last Release

1214d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/81402dcd0a07ad550b7f80f5871e7c302770b29d4c73a52fc35ba697f702d56e?d=identicon)[arslanim](/maintainers/arslanim)

---

Top Contributors

[![arslanim](https://avatars.githubusercontent.com/u/22678154?v=4)](https://github.com/arslanim "arslanim (29 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

iso-3166-1iso-3166-1-code-validatorsiso-standard

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rocketfellows-iso-standard-3166-validation/health.svg)

```
[![Health](https://phpackages.com/badges/rocketfellows-iso-standard-3166-validation/health.svg)](https://phpackages.com/packages/rocketfellows-iso-standard-3166-validation)
```

PHPackages © 2026

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