Skip to content

detain/zip-zapper

Repository files navigation

Zip Zapper

Validates Zip / Postal type codes by country with some features

Latest Stable Version Total Downloads Latest Unstable Version License Monthly Downloads Daily Downloads Reference Status Build Status Code Climate Scrutinizer Code Quality Codacy Badge

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