PHPackages                             jp3cki/yii2-jp-phone-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-phone-validator

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

jp3cki/yii2-jp-phone-validator
==============================

Phone number validator for Yii Framework2

v4.0.0(1y ago)0103MITPHPPHP &gt;= 8.1CI passing

Since Mar 18Pushed 4d ago1 watchersCompare

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

READMEChangelogDependencies (6)Versions (14)Used By (0)

yii2-jp-phone-validator
=======================

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

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

[![License](https://camo.githubusercontent.com/b35cb115018e09a101e6bfeeb81dbbfeaf35d41f04fc779b7b8fa3eace71aa8f/68747470733a2f2f706f7365722e707567782e6f72672f6a7033636b692f796969322d6a702d70686f6e652d76616c696461746f722f6c6963656e73652e737667)](https://packagist.org/packages/jp3cki/yii2-jp-phone-validator)[![Latest Stable Version](https://camo.githubusercontent.com/7b6ad9de33c84981207bc2de245e88875f9c05ea7e9005d536713764ffedc243/68747470733a2f2f706f7365722e707567782e6f72672f6a7033636b692f796969322d6a702d70686f6e652d76616c696461746f722f762f737461626c652e737667)](https://packagist.org/packages/jp3cki/yii2-jp-phone-validator)

動作環境
----

[](#動作環境)

- PHP 8.1 以上
- Yii framework ~2.0.51

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

[](#インストール)

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

使い方
---

[](#使い方)

### JpPhoneValidator

[](#jpphonevalidator)

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

市外局番が存在するかなどのチェックは行えますが、番号が実在することは確認できません。

フリーダイヤル等を許容するかどうか、ハイフンを許容するかどうかを設定できます（ハイフンの位置が間違っている場合はエラーになります）。 `110` 等の特番は扱えません。

Model class example:

```
declare(strict_types=1);

namespace app\models;

use Override;
use jp3cki\yii2\jpphone\JpPhoneValidator;
use yii\base\Model;

final class YourCustomForm extends Model
{
    public ?string $value;

    /**
     * @inheritdoc
     */
    #[Override]
    public function rules()
    {
        return [
            [['value'], JpPhoneValidator::class,
                'types' => JpPhoneValidator::FLAG_CONSUMERS, // 意味は後述
                'hyphen' => null, // 意味は後述
            ],
        ];
    }
}
```

`types`: 許容する電話番号の種類を設定します。複数の種類を受け入れる場合は bit-or `|` で接続します。デフォルトは `FLAG_CONSUMERS` です。

- `FLAG_LANDLINE`: 固定電話の番号を受け入れます。
- `FLAG_MOBILE`: `090` `080` `070` の携帯電話・PHSを受け入れます（番号ポータビリティ等の都合により、電話会社を識別したりPHSを識別したりはできません）。
- `FLAG_IP_PHONE`: `050` のIP電話を受け入れます（050でないIP電話は固定電話と区別がつきません）。
- `FLAG_FREE_DIAL`: `0120` のフリーダイヤルを受け入れます。ハイフンの位置は`0120-000-000`か`0120-00-0000`を受け入れるようになっています。 `FLAG_FREE_ACCESS` も参照してください。
- `FLAG_FREE_ACCESS`: `0800` のフリーアクセスを受け入れます。 `FLAG_FREE_DIAL` も参照してください。
- `FLAG_NAV_DIAL`: `0570` のナビダイヤルを受け入れます。
- `FLAG_PAGER`: （廃止）

利便性のために次の定数も準備されています。

- `FLAG_CONSUMERS`: `FLAG_LANDLINE|FLAG_MOBILE|FLAG_IP_PHONE`。顧客情報を登録してもらう際に一般的に必要となりそうな番号です。
- `FLAG_ALL`: サポートしている全ての種類を受け入れます。

なお、`FLAG_FREE_DIAL` と `FLAG_FREE_ACCESS` を分けて設定する意味はあまりないものと推測されます。

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

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

ライセンス
-----

[](#ライセンス)

[The MIT License](https://github.com/fetus-hina/yii2-jp-phone-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.

```

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

[](#非互換の更新)

- v3.0 → v4.0

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

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

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

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance72

Regular maintenance activity

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 96.7% 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 ~349 days

Recently: every ~239 days

Total

11

Last Release

588d ago

Major Versions

v1.0.4 → v2.0.02019-11-18

v2.0.4 → v3.0.02024-06-03

v3.0.0 → v4.0.02024-10-08

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

v2.0.0PHP &gt;= 7.1.0

v3.0.0PHP &gt;= 7.3.0

v4.0.0PHP &gt;= 8.1

### 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 (116 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")

---

Tags

validatorphoneyii2extensionjapantelephonetel

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[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)
