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

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

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

rocketfellows/iso-standard-3166-validation

最新稳定版本:v1.0.0

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.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固