detain/zip-zapper

Validates Zip/Postal Codes for any country and gives that countries name for thier verions of Zip/Post code

v2.0.0 2019-07-23 15:34 UTC

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

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