PHPackages                             sllh/iso-codes-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. sllh/iso-codes-validator

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

sllh/iso-codes-validator
========================

Symfony validator wrapper of ronanguilloux/isocodes

v4.2.0(2y ago)37299.8k↓27.8%10[28 issues](https://github.com/Soullivaneuh/IsoCodesValidator/issues)[1 PRs](https://github.com/Soullivaneuh/IsoCodesValidator/pulls)2MITPHPPHP ^7.4 || ^8.0

Since Apr 23Pushed 2y ago3 watchersCompare

[ Source](https://github.com/Soullivaneuh/IsoCodesValidator)[ Packagist](https://packagist.org/packages/sllh/iso-codes-validator)[ RSS](/packages/sllh-iso-codes-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (10)Versions (28)Used By (2)

IsoCodesValidator
=================

[](#isocodesvalidator)

Symfony validator wrapper of [IsoCodes](https://github.com/ronanguilloux/IsoCodes) project.

[![Latest Stable Version](https://camo.githubusercontent.com/86096d6dcc2f6378f2f5ae928d52f6bae79b35296107bf1bd6987fe2073b20bf/68747470733a2f2f706f7365722e707567782e6f72672f736c6c682f69736f2d636f6465732d76616c696461746f722f762f737461626c65)](https://packagist.org/packages/sllh/iso-codes-validator)[![Latest Unstable Version](https://camo.githubusercontent.com/4e73b6e79bba71915a8c221aab63ef58ec41f86c6e0622ad511491cffa84967a/68747470733a2f2f706f7365722e707567782e6f72672f736c6c682f69736f2d636f6465732d76616c696461746f722f762f756e737461626c65)](https://packagist.org/packages/sllh/iso-codes-validator)[![License](https://camo.githubusercontent.com/549ad7f66400482741fa20c961201d9b9d44329f74ef036fd0d60865cca11870/68747470733a2f2f706f7365722e707567782e6f72672f736c6c682f69736f2d636f6465732d76616c696461746f722f6c6963656e7365)](https://packagist.org/packages/sllh/iso-codes-validator)[![Dependency Status](https://camo.githubusercontent.com/5457c435c2e9423673b4f731002ea26e1f9648d0b6a1c258903733405fbb0f15/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f7068702f736c6c683a69736f2d636f6465732d76616c696461746f722f62616467652e737667)](https://www.versioneye.com/php/sllh:iso-codes-validator)[![Reference Status](https://camo.githubusercontent.com/052d6d5e587fd57e9b91a432d2fa676c128122d5ee9cf37f0ac600600293feeb/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f7068702f736c6c683a69736f2d636f6465732d76616c696461746f722f7265666572656e63655f62616467652e737667)](https://www.versioneye.com/php/sllh:iso-codes-validator/references)

[![Total Downloads](https://camo.githubusercontent.com/c18a7b554a21c3a71aab3013ef0889bb1f88cd19aa833d8e8b325a6055607cbe/68747470733a2f2f706f7365722e707567782e6f72672f736c6c682f69736f2d636f6465732d76616c696461746f722f646f776e6c6f616473)](https://packagist.org/packages/sllh/iso-codes-validator)[![Monthly Downloads](https://camo.githubusercontent.com/34280b315afb0ee0e3b8c0a1fa107db5c4b9571fe43addf8eb77a4aa0f6323b0/68747470733a2f2f706f7365722e707567782e6f72672f736c6c682f69736f2d636f6465732d76616c696461746f722f642f6d6f6e74686c79)](https://packagist.org/packages/sllh/iso-codes-validator)[![Daily Downloads](https://camo.githubusercontent.com/e4945beaf4424a9aed553b0ede20d263b8e3b3e8cceaea978fdecf4b9736bbe9/68747470733a2f2f706f7365722e707567782e6f72672f736c6c682f69736f2d636f6465732d76616c696461746f722f642f6461696c79)](https://packagist.org/packages/sllh/iso-codes-validator)

[![Build Status](https://camo.githubusercontent.com/abc0ed5a6621f8d1b050f7439fd9074e4c5b69e47f0fbdd109d791f3dca1e8dc/68747470733a2f2f7472617669732d63692e6f72672f536f756c6c6976616e6575682f49736f436f64657356616c696461746f722e7376673f6272616e63683d332e78)](https://travis-ci.org/Soullivaneuh/IsoCodesValidator)[![AppVeyor Status](https://camo.githubusercontent.com/3b051f07167b2497f7a6e502f596f0ee465b1ab2941ea933fe7aca206c7a7389/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f36686131676364763675776734756b632f6272616e63682f332e783f7376673d74727565)](https://ci.appveyor.com/project/Soullivaneuh/isocodesvalidator)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/086ea234c9977652b912624bcc8802f4eac5017b8acdaec708130b926527a9dd/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f536f756c6c6976616e6575682f49736f436f64657356616c696461746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d332e78)](https://scrutinizer-ci.com/g/Soullivaneuh/IsoCodesValidator/?branch=3.x)[![Code Climate](https://camo.githubusercontent.com/2263a7221945f93a9c0fe8b7b0f65fd6ebbc8d31e731e3561531a67f71acc89c/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f536f756c6c6976616e6575682f49736f436f64657356616c696461746f722f6261646765732f6770612e737667)](https://codeclimate.com/github/Soullivaneuh/IsoCodesValidator)[![Coverage Status](https://camo.githubusercontent.com/9c7465871dd9f883320b6e707f32ff1156efc87b31c11f884e7c4f671ab05c4c/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f536f756c6c6976616e6575682f49736f436f64657356616c696461746f722f62616467652e7376673f6272616e63683d332e78)](https://coveralls.io/r/Soullivaneuh/IsoCodesValidator?branch=3.x)[![SensioLabsInsight](https://camo.githubusercontent.com/1d71bc2416b0184bdd69cb971c1c14d0388d7e8b98fcdb693a83a1c003393784/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f31356532636665642d636662382d343835362d616330642d3932373638666330633332342f6d696e692e706e67)](https://insight.sensiolabs.com/projects/15e2cfed-cfb8-4856-ac0d-92768fc0c324)

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

[](#installation)

First of all, you need to require this library through composer:

```
$ composer require sllh/iso-codes-validator
```

After this, you can use it as is.

If you are using it on a **Symfony** project, you should read the following instructions for a better integration.

### As a Symfony bundle

[](#as-a-symfony-bundle)

If your project **is not using** [Symfony Full Stack](http://symfony.com/projects/symfonyfs), you must add the following dependencies:

```
$ composer require symfony/dependency-injection symfony/http-kernel symfony/finder
```

#### Translations

[](#translations)

If you wish to use default validator messages translations in this bundle, you have to make sure you have translator enabled in your config.

```
# app/config/config.yml

framework:
    translator: ~
```

#### Enable the bundle

[](#enable-the-bundle)

```
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new SLLH\IsoCodesValidator\Bridge\Symfony\Bundle\SLLHIsoCodesValidatorBundle(),
    );
}
```

Usage
-----

[](#usage)

IsoCodesValidator is based on Symfony [Validator](http://symfony.com/components/Validator) library.

### Manual usage

[](#manual-usage)

Create and use IsoCodes constraints by using the Symfony [Validation](https://github.com/symfony/Validator#usage) class:

```
use Symfony\Component\Validator\Validation;
use SLLH\IsoCodesValidator\Constraints\Vat;

$validator = Validation::createValidator();

$violations = $validator->validateValue('DE123456789', new Vat());
```

### With annotations

[](#with-annotations)

> Validation of objects is possible using "constraint mapping". With such a mapping you can put constraints onto properties and objects of classes. Whenever an object of this class is validated, its properties and method results are matched against the constraints.

```
use Symfony\Component\Validator\Validation;
use Symfony\Component\Validator\Constraints as Assert;
use SLLH\IsoCodesValidator\Constraints as IsoCodesAssert;

class Company
{
    /**
     * @Assert\NotBlank
     * @IsoCodesAssert\Siret
     */
    private $siret;

    /**
     * @Assert\NotBlank
     * @IsoCodesAssert\Siren
     */
    private $siren;

    /**
     * @IsoCodesAssert\Vat
     */
    private $vat;

    /**
     * @IsoCodesAssert\ZipCode(country = "FR")
     */
    private $zipCode;

    public function __construct($siret, $siren, $vat, $zipCode)
    {
        $this->siret = $siret;
        $this->siren = $siren;
        $this->vat = $vat;
        $this->zipCode = $zipCode
    }
}

$validator = Validation::createValidatorBuilder()
    ->enableAnnotationMapping()
    ->getValidator();

$company = new Company('48853781200015', '432167567', 'DE123456789', '59000');

$violations = $validator->validate($company);
```

Constraints reference
---------------------

[](#constraints-reference)

Constraints classes can be found on [src/Constraints](src/Constraints).

All works "as is" without any options unless `message`.

Only [ZipCode](src/Constraints/ZipCode.php) constraint accept a `country` option to limit validation ('all' by default).

Please note that some [IsoCodes](https://github.com/ronanguilloux/IsoCodes/tree/master/src/IsoCodes) classes are already implemented on [Symfony Validator component](http://symfony.com/doc/current/reference/constraints.html). It's up to you to decide which one to use.

If you think an IsoCodes class is missing, feel free to open an issue or make a PR.

License
-------

[](#license)

This bundle is under the MIT license. See the complete license on the [LICENSE](LICENSE) file.

TODO
----

[](#todo)

- Try to implement [OrganismeType12NormeB2](https://github.com/ronanguilloux/IsoCodes/blob/master/src/IsoCodes/OrganismeType12NormeB2.php) (Maybe with a special form type?)
- Implement and test xml/yaml assert config for Symfony:

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance5

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 99.5% 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 ~122 days

Recently: every ~477 days

Total

26

Last Release

972d ago

Major Versions

1.x-dev → v2.0.02016-04-15

v2.1.0 → v3.0.02016-05-21

3.x-dev → v4.0.02018-06-28

PHP version history (6 changes)v1.0.0PHP &gt;=5.3.3

v1.0.1PHP &gt;=5.4

v1.2.1PHP ^5.4|^7.0

v2.0.0PHP ^5.6|^7.0

2.x-devPHP ^5.6 || ^7.0

v4.1.0PHP ^7.4 || ^8.0

### Community

Maintainers

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

---

Top Contributors

[![soullivaneuh](https://avatars.githubusercontent.com/u/1698357?v=4)](https://github.com/soullivaneuh "soullivaneuh (391 commits)")[![Benjamin-Porquet](https://avatars.githubusercontent.com/u/51694115?v=4)](https://github.com/Benjamin-Porquet "Benjamin-Porquet (1 commits)")[![clad20](https://avatars.githubusercontent.com/u/15609196?v=4)](https://github.com/clad20 "clad20 (1 commits)")

---

Tags

symfonyvalidatorISO codes

### Embed Badge

![Health badge](/badges/sllh-iso-codes-validator/health.svg)

```
[![Health](https://phpackages.com/badges/sllh-iso-codes-validator/health.svg)](https://phpackages.com/packages/sllh-iso-codes-validator)
```

###  Alternatives

[rollerworks/password-strength-validator

Password-strength validator for Symfony

1455.7M6](/packages/rollerworks-password-strength-validator)[barbieswimcrew/zip-code-validator

Constraint class for international zipcode validation

772.3M](/packages/barbieswimcrew-zip-code-validator)

PHPackages © 2026

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