rocketfellows/iso-standard-3166-validation 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rocketfellows/iso-standard-3166-validation

Composer 安装命令:

composer require rocketfellows/iso-standard-3166-validation

包简介

README 文档

README

Code Coverage Badge

This component consist of several country code validators. Validated country code formats:

  • alpha2
  • alpha3
  • full name
  • numeric code

It also can validate batch country code values and returns array of invalid given codes (or full name).

Installation

composer require rocketfellows/iso-standard-3166-validation

Validate alpha2 code usage example

Note: validation case-insensitive.

Static usage

Valid alpha2 country code:

Alpha2::create()->isValid('DE');
Alpha2::create()->isValid('de');
Alpha2::create()->isValid('De');
Alpha2::create()->isValid('dE');

Returns:

true
true
true
true

Invalid alpha2 country code:

Alpha2::create()->isValid('OO');

Returns:

false

New instance creation usage

Valid alpha2 country code:

$validator = new Alpha2();
$validator->isValid('DE')

Returns:

true

Invalid alpha2 country code:

$validator = new Alpha2();
$validator->isValid('OO')

Returns:

false

Validate alpha3 code usage example

Note: validation case-insensitive.

Static usage

Valid alpha3 country code:

Alpha3::create()->isValid('GBR')
Alpha3::create()->isValid('gbr')
Alpha3::create()->isValid('Gbr')

Returns:

true
true
true

Invalid alpha3 country code:

Alpha3::create()->isValid('FOO');

Returns:

false

New instance creation usage

Valid alpha3 country code:

$validator = new Alpha3();
$validator->isValid('GBR')

Returns:

true

Invalid alpha3 country code:

$validator = new Alpha3();
$validator->isValid('FOO')

Returns:

false

Validate numeric code usage example

Static usage

Valid country numeric code:

NumericCode::create()->isValid('646');

Returns:

true

Invalid country numeric code:

NumericCode::create()->isValid('000');

Returns:

false

New instance creation usage

Valid country numeric code:

$validator = new NumericCode();
$validator->isValid('646')

Returns:

true

Invalid country numeric code:

$validator = new NumericCode();
$validator->isValid('000')

Returns:

false

Validate country name usage example

Note: validation case-sensitive.

Static usage

Valid country name:

Name::create()->isValid('Northern Mariana Islands');

Returns:

true

Invalid country name:

Name::create()->isValid('foo');

Returns:

false

New instance creation usage

Valid country name:

$validator = new Name();
$validator->isValid('Northern Mariana Islands')

Returns:

true

Invalid country name:

$validator = new Name();
$validator->isValid('foo')

Returns:

false

Validate alpha2 batch codes usage example

Note: validation case-insensitive.

Static usage

Validation:

Alpha2Batch::create()->getInvalidValues(['DE', 'HH', 'BY', 'ZZ', 'GB',]);

Returns:

['HH', 'ZZ']

New instance creation usage

Validation:

$validator = new Alpha2Batch(Alpha2::create()); // possible inject other Alpha2 validator implementation
$validator->getInvalidValues(['DE', 'HH', 'BY', 'ZZ', 'GB',]);

Returns:

['HH', 'ZZ']

Validate alpha3 batch codes usage example

Note: validation case-insensitive.

Static usage

Validation:

Alpha3Batch::create()->getInvalidValues(['GBR', 'HH', 'RUS', 'ZZ', 'DEU',]);

Returns:

['HH', 'ZZ']

New instance creation usage

Validation:

$validator = new Alpha3Batch(Alpha3::create()); // possible inject other Alpha3 validator implementation
$validator->getInvalidValues(['GBR', 'HH', 'RUS', 'ZZ', 'DEU',]);

Returns:

['HH', 'ZZ']

Validate numeric codes batch usage example

Static usage

Validation:

NumericCodeBatch::create()->getInvalidValues(['882', '000', '674', '111', '678',]);

Returns:

['000', '111']

New instance creation usage

Validation:

$validator = new NumericCodeBatch(NumericCode::create()); // possible inject other NumericCode validator implementation
$validator->getInvalidValues(['882', '000', '674', '111', '678',]);

Returns:

['000', '111']

Validate country names batch usage example

Note: validation case-sensitive.

Static usage

Validation:

NameBatch::create()->getInvalidValues(['Samoa', 'foo', 'Sao Tome and Principe', 'bar', 'Saudi Arabia',]);

Returns:

['foo', 'bar']

New instance creation usage

Validation:

$validator = new NameBatch(Name::create()); // possible inject other Name validator implementation
$validator->getInvalidValues(['Samoa', 'foo', 'Sao Tome and Principe', 'bar', 'Saudi Arabia',]);

Returns:

['foo', 'bar']

Contributing

Welcome to pull requests. If there is a major changes, first please open an issue for discussion.

Please make sure to update tests as appropriate.

rocketfellows/iso-standard-3166-validation 适用场景与选型建议

rocketfellows/iso-standard-3166-validation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 196 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 01 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 rocketfellows/iso-standard-3166-validation 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rocketfellows/iso-standard-3166-validation 我们能提供哪些服务?
定制开发 / 二次开发

基于 rocketfellows/iso-standard-3166-validation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 196
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 12
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-11