https://github.com/detain/zip-zapper
Validates Zip / Postal type codes by country
https://github.com/detain/zip-zapper
postal-code validation zipcode
Last synced: 2 months ago
JSON representation
Validates Zip / Postal type codes by country
- Host: GitHub
- URL: https://github.com/detain/zip-zapper
- Owner: detain
- License: mit
- Created: 2017-03-21T23:10:52.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-11T15:52:10.000Z (over 2 years ago)
- Last Synced: 2024-10-29T00:41:53.580Z (9 months ago)
- Topics: postal-code, validation, zipcode
- Language: PHP
- Size: 130 KB
- Stars: 7
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Zip Zapper
Validates Zip / Postal type codes by country with some features
[](https://packagist.org/packages/detain/zip-zapper)
[](https://packagist.org/packages/detain/zip-zapper)
[](//packagist.org/packages/detain/zip-zapper)
[](https://packagist.org/packages/detain/zip-zapper)
[](https://packagist.org/packages/detain/zip-zapper)
[](https://packagist.org/packages/detain/zip-zapper)
[](https://www.versioneye.com/php/detain:zip-zapper/references)
[](https://travis-ci.org/detain/zip-zapper)
[](https://codeclimate.com/github/detain/zip-zapper)
[](https://scrutinizer-ci.com/g/detain/zip-zapper/?branch=master)
[](https://www.codacy.com/app/detain/zip-zapper)[Postal Systems by Country](https://en.wikipedia.org/wiki/Category:Postal_system)
[DMOZ Post/Zip Code Info+DB](http://dmoztools.net/Reference/Directories/Address_and_Phone_Numbers/Postal_Codes/)
[List of Postal Codes](https://en.wikipedia.org/wiki/List_of_postal_codes)Based on a similar project [sirprize/postal-code-validator](https://github.com/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`