PHPackages                             jp3cki/yii2-jp-postalcode-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. jp3cki/yii2-jp-postalcode-validator

ActiveYii2-extension[Validation &amp; Sanitization](/categories/validation)

jp3cki/yii2-jp-postalcode-validator
===================================

Postal code validator for Yii Framework2

v5.0.2(1mo ago)055[1 PRs](https://github.com/fetus-hina/yii2-jp-postalcode-validator/pulls)MITPHPPHP &gt;= 8.2.0CI passing

Since Apr 9Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/fetus-hina/yii2-jp-postalcode-validator)[ Packagist](https://packagist.org/packages/jp3cki/yii2-jp-postalcode-validator)[ RSS](/packages/jp3cki-yii2-jp-postalcode-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (17)Versions (67)Used By (0)

yii2-jp-postalcode-validator
============================

[](#yii2-jp-postalcode-validator)

日本の郵便番号をチェックする Yii Framework2 用のバリデータです。

[![License](https://camo.githubusercontent.com/86817132646e848c285a375e7b2276a352da1fdc8c50bf9944c3651826ac2bb3/68747470733a2f2f706f7365722e707567782e6f72672f6a7033636b692f796969322d6a702d706f7374616c636f64652d76616c696461746f722f6c6963656e73652e737667)](https://packagist.org/packages/jp3cki/yii2-jp-postalcode-validator)[![Latest Stable Version](https://camo.githubusercontent.com/43842efbef7c38974a27fde918b89406ef64ed66b441d78b77ec7c56d3580d4d/68747470733a2f2f706f7365722e707567782e6f72672f6a7033636b692f796969322d6a702d706f7374616c636f64652d76616c696461746f722f762f737461626c652e737667)](https://packagist.org/packages/jp3cki/yii2-jp-postalcode-validator)

動作環境
----

[](#動作環境)

- PHP 8.2 以上
- Yii framework 2.0

インストール
------

[](#インストール)

1. [Composer](https://getcomposer.org/) をダウンロードして使用可能な状態にします。
2. 必要であれば Yii Framework2 のプロジェクトを作成します。
3. `php composer.phar require jp3cki/yii2-jp-postalcode-validator`

使い方
---

[](#使い方)

### JpPostalCodeValidator

[](#jppostalcodevalidator)

このバリデータは入力が日本の郵便番号らしい文字列であることを検証します。

通常の郵便番号の他、事業所等に割り当てられた番号も検証することができます。

Model class example:

```
namespace app\models;

use yii\base\Model;
use jp3cki\yii2\validators\JpPostalCodeValidator;

class YourCustomForm extends Model
{
    public $value;

    public function rules()
    {
        return [
            [['value'], JpPostalCodeValidator::class,
                'hyphen' => null, // 意味は後述
            ],
        ];
    }
}
```

`hyphen`: ハイフンの許可状況を設定します。

- `null`: ハイフンの有無を気にしません（ハイフンが記入されている場合は正しい位置にハイフンがある必要があります）。
- `true`: ハイフンを必須とします。（正しい位置にハイフンがある必要があります）
- `false`: ハイフンを許容しません。（数字のみの羅列である必要があります）

ライセンス
-----

[](#ライセンス)

[The MIT License](https://github.com/fetus-hina/yii2-jp-postalcode-validator/blob/master/LICENSE).

```
The MIT License (MIT)

Copyright (c) 2015-2025 AIZAWA Hina

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

```

非互換の更新
------

[](#非互換の更新)

- v4.0 → v5.0

    - PHPの要求バージョンを8.2に引き上げました。コード上の非互換はありません。
- v3.0 → v4.0

    - PHPの要求バージョンを8.1に引き上げました。コード上の非互換はありません。
- v2.0 → v3.0

    - PHPの要求バージョンを7.2に引き上げました。コード上の非互換はありません。
- v1.0 → v2.0

    - PHPの要求バージョンを引き上げました。コード上の非互換はありません。

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance87

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity90

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~62 days

Recently: every ~38 days

Total

65

Last Release

46d ago

Major Versions

v1.0.4 → v2.0.02019-11-18

v2.x-dev → v3.0.02022-03-11

v3.0.21 → v4.0.02023-11-30

v4.0.22 → v5.0.02025-11-30

PHP version history (5 changes)1.0.0PHP &gt;=5.4.0

v2.0.0PHP &gt;= 7.1.0

v3.0.0PHP &gt;= 7.2.0

v4.0.0PHP &gt;= 8.1.0

v5.0.0PHP &gt;= 8.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c07587f82c7761e4445d95292041d543aeda609e74cb366517bb80c4423d729f?d=identicon)[AIZAWA Hina](/maintainers/AIZAWA%20Hina)

---

Top Contributors

[![fetus-hina](https://avatars.githubusercontent.com/u/848666?v=4)](https://github.com/fetus-hina "fetus-hina (238 commits)")

---

Tags

validatoryii2extensionzipcodejapanpostalcode

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/jp3cki-yii2-jp-postalcode-validator/health.svg)

```
[![Health](https://phpackages.com/badges/jp3cki-yii2-jp-postalcode-validator/health.svg)](https://phpackages.com/packages/jp3cki-yii2-jp-postalcode-validator)
```

###  Alternatives

[barbieswimcrew/zip-code-validator

Constraint class for international zipcode validation

772.3M](/packages/barbieswimcrew-zip-code-validator)[kdn/yii2-domain-validator

Domain name validator for Yii 2.

11122.3k1](/packages/kdn-yii2-domain-validator)[nepstor/yii2-datetime-compare-validator

Yii2 validator for compare datetime.

1283.7k1](/packages/nepstor-yii2-datetime-compare-validator)[codeonyii/yii2-at-least-validator

Validates at least one (or more) attributes.

28253.5k1](/packages/codeonyii-yii2-at-least-validator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
