Skip to content
Validate Formatting Of World-Wide Postal Codes
PHP
Branch: master
Clone or download
sirprize Merge pull request #18 from Genflow/hotfix/GEN-758
GEN-758 fix validation for Lithuania 'LT'
Latest commit 40e569e Sep 19, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src GEN-758 fix validation for Lithuania 'LT' Sep 17, 2019
tests Refactoring Jul 20, 2019
.gitignore Restore composer.lock Aug 3, 2019
.travis.yml Test enhancement Jun 7, 2018
LICENSE Initial import Aug 25, 2012
composer.json Refactoring Jul 20, 2019
composer.lock Restore composer.lock Aug 3, 2019
phpunit.xml.dist Refactoring Jul 20, 2019
readme.md Refactoring Jul 20, 2019

readme.md

Postal-code-validator

Validate Formatting of World-Wide Postal Codes according this "List of postal codes" article on Wikipedia

Usage

Check If Country Is Supported

use Sirprize\PostalCodeValidator\Validator;

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

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

use Sirprize\PostalCodeValidator\Validator;

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

Formatting

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

Country Codes

Postal-code-validator uses ISO 3166 2-letter country codes

License

See LICENSE.

You can’t perform that action at this time.