Validate Formatting of World-Wide Postal Codes according this "List of postal codes" article on Wikipedia
composer require sirprize/postal-code-validator
use Sirprize\PostalCodeValidator\Validator;
$validator = new Validator();
$validator->hasCountry('CH'); // returns true
use Sirprize\PostalCodeValidator\Validator;
$validator = new Validator();
$validator->isValid('CH', 'usjU87jsdf'); // returns false
$validator->isValid('CH', '3007'); // returns true
use Sirprize\PostalCodeValidator\Validator;
$validator = new Validator();
$validator->getFormats('GB'); // returns ['@@## #@@', '@#@ #@@', '@@# #@@', '@@#@ #@@', '@## #@@', '@# #@@']
#
=0-9
@
=a-zA-Z
Postal-code-validator uses ISO 3166 2-letter country codes
See LICENSE.