PHPackages                             sirprize/postal-code-validator - 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. sirprize/postal-code-validator

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

sirprize/postal-code-validator
==============================

Validate Formatting Of World-Wide Postal Codes

1.5.1(3mo ago)782.0M↓35.1%25[3 issues](https://github.com/sirprize/postal-code-validator/issues)1MITPHPPHP ^7.2 || ^8.0CI failing

Since Mar 11Pushed 3mo ago5 watchersCompare

[ Source](https://github.com/sirprize/postal-code-validator)[ Packagist](https://packagist.org/packages/sirprize/postal-code-validator)[ Docs](https://github.com/sirprize/postal-code-validator)[ RSS](/packages/sirprize-postal-code-validator/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (2)Versions (20)Used By (1)

Postal-code-validator
=====================

[](#postal-code-validator)

Validate Formatting of World-Wide Postal Codes according this ["List of postal codes" article on Wikipedia](https://en.wikipedia.org/wiki/List_of_postal_codes)

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

[](#installation)

```
composer require sirprize/postal-code-validator

```

Usage
-----

[](#usage)

### Check If Country Is Supported

[](#check-if-country-is-supported)

```
use Sirprize\PostalCodeValidator\Validator;

$validator = new Validator();
$validator->hasCountry('CH'); // returns true

```

### Check If Postal Code Is Properly Formatted

[](#check-if-postal-code-is-properly-formatted)

```
use Sirprize\PostalCodeValidator\Validator;

$validator = new Validator();
$validator->isValid('CH', 'usjU87jsdf'); // returns false
$validator->isValid('CH', '3007'); // returns true

```

### Get The Possible Formats For a Specific Country

[](#get-the-possible-formats-for-a-specific-country)

```
use Sirprize\PostalCodeValidator\Validator;

$validator = new Validator();
$validator->getFormats('GB'); // returns ['@@## #@@', '@#@ #@@', '@@# #@@', '@@#@ #@@', '@## #@@', '@# #@@']

```

Formatting
----------

[](#formatting)

- `#` = `0-9`
- `@` = `a-zA-Z`

Country Codes
-------------

[](#country-codes)

Postal-code-validator uses [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) 2-letter country codes

License
-------

[](#license)

See LICENSE.

###  Health Score

63

—

FairBetter than 99% of packages

Maintenance78

Regular maintenance activity

Popularity56

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 61.8% 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 ~223 days

Recently: every ~293 days

Total

19

Last Release

113d ago

PHP version history (3 changes)1.0.0PHP &gt;=5.3.2

1.3.6PHP &gt;=7.2

1.4.0PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/81617?v=4)[Christian Högl](/maintainers/sirprize)[@sirprize](https://github.com/sirprize)

---

Top Contributors

[![sirprize](https://avatars.githubusercontent.com/u/81617?v=4)](https://github.com/sirprize "sirprize (42 commits)")[![niektenhoopen](https://avatars.githubusercontent.com/u/3450011?v=4)](https://github.com/niektenhoopen "niektenhoopen (6 commits)")[![dmnc](https://avatars.githubusercontent.com/u/144790?v=4)](https://github.com/dmnc "dmnc (4 commits)")[![rogervila](https://avatars.githubusercontent.com/u/6053012?v=4)](https://github.com/rogervila "rogervila (3 commits)")[![xpavp03](https://avatars.githubusercontent.com/u/853656?v=4)](https://github.com/xpavp03 "xpavp03 (2 commits)")[![fogush](https://avatars.githubusercontent.com/u/2500435?v=4)](https://github.com/fogush "fogush (2 commits)")[![ickbinhier](https://avatars.githubusercontent.com/u/2810904?v=4)](https://github.com/ickbinhier "ickbinhier (2 commits)")[![landi029](https://avatars.githubusercontent.com/u/17082066?v=4)](https://github.com/landi029 "landi029 (1 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")[![karolisg](https://avatars.githubusercontent.com/u/1695346?v=4)](https://github.com/karolisg "karolisg (1 commits)")[![rvelhote](https://avatars.githubusercontent.com/u/59101?v=4)](https://github.com/rvelhote "rvelhote (1 commits)")[![simonschaufi](https://avatars.githubusercontent.com/u/941794?v=4)](https://github.com/simonschaufi "simonschaufi (1 commits)")[![DrMerk](https://avatars.githubusercontent.com/u/121562885?v=4)](https://github.com/DrMerk "DrMerk (1 commits)")[![davidaniel](https://avatars.githubusercontent.com/u/1495114?v=4)](https://github.com/davidaniel "davidaniel (1 commits)")

---

Tags

validatorzip codepostal-code

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sirprize-postal-code-validator/health.svg)

```
[![Health](https://phpackages.com/badges/sirprize-postal-code-validator/health.svg)](https://phpackages.com/packages/sirprize-postal-code-validator)
```

###  Alternatives

[respect/validation

The most awesome validation engine ever created for PHP

6.0k39.9M413](/packages/respect-validation)[seld/jsonlint

JSON Linter

1.3k228.7M271](/packages/seld-jsonlint)[composer/spdx-licenses

SPDX licenses list and validation library.

1.4k193.5M40](/packages/composer-spdx-licenses)[barbieswimcrew/zip-code-validator

Constraint class for international zipcode validation

772.5M](/packages/barbieswimcrew-zip-code-validator)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel

3893.6M1](/packages/axlon-laravel-postal-code-validation)[opis/json-schema

Json Schema Validator for PHP

65243.6M299](/packages/opis-json-schema)

PHPackages © 2026

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