pixelpeter / laravel-isocodes-validation
Laravel 12+ wrapper for the IsoCodes Validation library from ronanguilloux
Package info
github.com/pixelpeter/laravel-isocodes-validation
pkg:composer/pixelpeter/laravel-isocodes-validation
Requires
- php: ^8.3|^8.4|^8.5
- laravel/framework: ^12.61.1|^13.0
- ronanguilloux/isocodes: ^2.4.1
Requires (Dev)
- larastan/larastan: ^3.7
- mockery/mockery: ^1.6
- orchestra/testbench: ^10.0|^11.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.5.8
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-17 09:36:09 UTC
README
A simple Laravel 12+ wrapper for the IsoCodes Validation library from ronanguilloux.
Version overview
From v13.0.0 on, the package major version matches the highest Laravel major version it supports, so ^13.0 covers
Laravel 13.x and 12.x. This is the only maintained line: master is where it is developed, and the v13.x branch
tracks it and carries the released state.
| Laravel | php | composer | branch |
|---|---|---|---|
| 13.x, 12.x | 8.5, 8.4, 8.3 | ^13.0 |
master, v13.x |
Deprecated releases
Earlier releases stay installable and unchanged, but they are no longer maintained: they receive no fixes and no further releases. Laravel 11.x and 10.x are past their security support window, and Composer refuses to install them because of published security advisories.
| Laravel | php | composer | tag | status |
|---|---|---|---|---|
| 12.x, 11.x, 10.x | 8.4, 8.3, 8.2 | ^12.0 |
v12.1.0 | deprecated, superseded by ^13.0 |
| 11.x, 10.x | 8.3, 8.2, 8.1 | ^10.0 |
v10.1.0 | deprecated, no successor |
| 9.x, 8.x | 8.2, 8.1, 8.0 | ^8.0 |
v8.1.1 | deprecated, no successor |
Installation
Install With Composer
composer require pixelpeter/laravel-isocodes-validation
Usage
Simple examples
// Checking out your e-commerce shopping cart? $payload = [ 'creditcard' => '12345679123456' ]; $rules = [ 'creditcard' => 'creditcard' ]; $validator = Validator::make($payload, $rules);
Examples with reference parameter
Some rules need a reference to be validated against (e.g. country for zipcode).
Just pass the name of the field holding the reference to the rule.
// Sending letters to the Labrador Islands ? $payload = [ 'zipcode' => 'A0A 1A0', 'country' => 'CA' ]; $rules = [ 'zipcode' => 'zipcode:country' ]; $validator = Validator::make($payload, $rules); // Publishing books? $payload = [ 'isbn' => '2-2110-4199-X', 'isbntype' => 13 ]; $rules = [ 'zipcode' => 'isbn:isbntype' ]; $validator = Validator::make($payload, $rules);
Example with arrays and dot notation
(added in v3.x)
As suggested by @otr-tomek I've added support for all validation methods using arrays in dot notation as an input.
$payload = [ 'data' => [ [ 'country' => 'DE', 'zipcode' => 63741 ], [ 'country' => 'AT', 'zipcode' => 1180 ] ] ]; $validator = Validator::make($payload, [ 'data.*.zipcode' => 'zipcode:data.*.country' ]);
Validation error messages
Error messages can contain the name and value of the field and the value of the reference
$payload = [ 'phonenumber' => 'invalid', 'country' => 'GB' ]; $rules = [ 'phonenumber' => 'phonenumber:country' ]; $validator = Validator::make($payload, $rules); print $validator->errors()->first(); // The value "invalid" of phonenumber is not valid for "GB".
More Examples
Refer to IsoCodes Validation library for more examples and documentation.
Testing
Run the tests with:
vendor/bin/phpunit
License
GNU General Public License v3.0 only. Please see License File for more information.