Skip to content

KacerCZ/postal-code-validator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Postal-code-validator

Validate Formatting of World-Wide Postal Codes

Usage

Check If Country Is Supported

use Sirprize\PostalCodeValidator\Validator;

$validator = new Validator();
$validator->hasCountry('CH'); // returns true

Check If Postal Code Is Properly Formatted

use Sirprize\PostalCodeValidator\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 Sirprize\PostalCodeValidator\Validator;

$validator = new Validator();
$validator->getFormats('GB'); // returns array('@# #@@', '@** #@@', '@@#* #@@')

Formatting

  • # = 0-9
  • @ = a-zA-Z
  • * = a-zA-Z0-9

Country Codes

Postal-code-validator uses ISO 3166 2-letter country codes

License

See LICENSE.

About

Validate Formatting Of World-Wide Postal Codes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%