detain / zip-zapper
Validates Zip/Postal Codes for any country and gives that countries name for thier verions of Zip/Post code
Installs: 1 245
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 2
Forks: 4
Open Issues: 2
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: ^4.8.35 | ^5.5 | ^6.5
This package is auto-updated.
Last update: 2024-10-29 02:07:27 UTC
README
Validates Zip / Postal type codes by country with some features
Postal Systems by Country
DMOZ Post/Zip Code Info+DB
List of Postal Codes
Based on a similar project sirprize/postal-code-validator but expanded on it adding over 100 new validations and updating ther others using mostly the Wikipedia postal codes list and some other features I needed in zip validation.
Installation
composer require detain/zip-zapper
Usage
Check If Country Is Supported
use Detain\ZipZapper\Validator;
$validator = new Validator();
$validator->hasCountry('CH'); // returns true
Check If Postal Code Is Properly Formatted
use Detain\ZipZapper\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 Detain\ZipZapper\Validator;
$validator = new Validator();
$validator->getFormats('GB'); // returns array('@@## #@@', '@#@ #@@', '@@# #@@', '@@#@ #@@', '@## #@@', '@# #@@')
Formatting
#
=0-9
@
=a-zA-Z