拘留/zip-zapper

验证任何国家的邮政编码,并提供该国家邮政编码的名称

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

This package is auto-updated.

Last update: 2024-09-29 01:48:36 UTC


README

使用一些功能验证各国的邮政/邮编类型代码

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

各国邮政系统
DMOZ邮政/邮编信息+数据库
邮编列表

基于类似项目 sirprize/postal-code-validator,但进行了扩展,增加了100多个验证,并使用维基百科的邮政编码列表和其他一些我需要的zip验证功能更新了其他验证。

安装

composer require detain/zip-zapper

使用方法

检查国家是否受支持

use Detain\ZipZapper\Validator;

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

检查邮政编码格式是否正确

use Detain\ZipZapper\Validator;

$validator = new Validator();
$validator->isValid('CH', 'usjU87jsdf'); // returns false
$validator->isValid('CH', '3007'); // returns true

获取特定国家的可能格式

use Detain\ZipZapper\Validator;

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

格式化

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