PHPackages                             godruoyi/laravel-idcard-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. godruoyi/laravel-idcard-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

godruoyi/laravel-idcard-validator
=================================

Laravel 身份证验证器

1.0.4(4y ago)95.6k1MITPHPCI failing

Since Apr 17Pushed 4y ago1 watchersCompare

[ Source](https://github.com/godruoyi/laravel-idcard-validator)[ Packagist](https://packagist.org/packages/godruoyi/laravel-idcard-validator)[ Docs](https://github.com/godruoyi/laravel-idcard-validator)[ RSS](/packages/godruoyi-laravel-idcard-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (7)Used By (0)

 laravel-idcard-validator
==========================

[](#-laravel-idcard-validator-)

[![Build Status](https://camo.githubusercontent.com/c4d1d26ec388131eff063c0767152b5f1b7ef442d0c5118519f285357efd982a/68747470733a2f2f7472617669732d63692e6f72672f676f6472756f79692f6c61726176656c2d6964636172642d76616c696461746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/godruoyi/laravel-idcard-validator)[![StyleCI](https://camo.githubusercontent.com/ce7c254ba5eeebe5608150ae3a12b3571f1cbc536814886ecbb8ad41c41aba39/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3138313830393133322f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/181809132)[![Latest Stable Version](https://camo.githubusercontent.com/23463676e4c34347f5d308043f2dc56b2a646b01edff0115128d53c5663649f0/68747470733a2f2f706f7365722e707567782e6f72672f676f6472756f79692f6c61726176656c2d6964636172642d76616c696461746f722f762f737461626c65)](https://packagist.org/packages/godruoyi/laravel-idcard-validator)[![Latest Unstable Version](https://camo.githubusercontent.com/206de6add9ea189e1f2a4f1073b8325e74fa0979e7e72e108e2846bc598b22f4/68747470733a2f2f706f7365722e707567782e6f72672f676f6472756f79692f6c61726176656c2d6964636172642d76616c696461746f722f762f756e737461626c65)](https://packagist.org/packages/godruoyi/laravel-idcard-validator)[![Total Downloads](https://camo.githubusercontent.com/a7519c7296afe48c789329ef8c0d6c3836aed2d4d2b1dee724d0f065b2700e03/68747470733a2f2f706f7365722e707567782e6f72672f676f6472756f79692f6c61726176656c2d6964636172642d76616c696461746f722f646f776e6c6f616473)](https://packagist.org/packages/godruoyi/laravel-idcard-validator)[![License](https://camo.githubusercontent.com/862d940dab464063d58d82133ebff50ec725da5ac7cc89b0aa16253db03cc1d0/68747470733a2f2f706f7365722e707567782e6f72672f676f6472756f79692f6c61726176656c2d6964636172642d76616c696461746f722f6c6963656e7365)](https://packagist.org/packages/godruoyi/laravel-idcard-validator)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/96e6dbcd7e70b774db0da172d413cfdccec882b5328afe1c94a057e0281cda09/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f676f6472756f79692f6c61726176656c2d6964636172642d76616c696461746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/godruoyi/laravel-idcard-validator/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/bc2afbe0c5329837c80dcf5b382a197f311a172e781fe070cfaa41c7ad5fe42d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f676f6472756f79692f6c61726176656c2d6964636172642d76616c696461746f722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/godruoyi/laravel-idcard-validator/?branch=master)[![FOSSA Status](https://camo.githubusercontent.com/6ef13d1d795ad61bf2feb944708a761d463a7f806d01cb8ff6a51d2ca9b23242/68747470733a2f2f6170702e666f7373612e636f6d2f6170692f70726f6a656374732f6769742532426769746875622e636f6d253246676f6472756f79692532466c61726176656c2d6964636172642d76616c696461746f722e7376673f747970653d736869656c64)](https://app.fossa.com/projects/git%2Bgithub.com%2Fgodruoyi%2Flaravel-idcard-validator?ref=badge_shield)

安装
--

[](#安装)

```
$ composer require godruoyi/laravel-idcard-validator -vvv
```

使用
--

[](#使用)

Laravel 版本小于 5.5 时，需要手动在 `app\config.php` 添加 `service provider`：

```
Godruoyi\LaravelIdCard\ServiceProvider::class,
```

通过 Validator 面门使用：

```
Validator::make([
    'idcard' => '110101199801012385',
], [
    'idcard' => 'required|string|idcard',
]);
```

通过 FormRequest 使用：

```
class UserRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'idcard' => 'required|idcard',

            // 或者
            'idcard' => ['required', new \Godruoyi\LaravelIdCard\Rule],
        ];
    }
}
```

验证不通过时，默认返回 `无效的身份证号码`。

License
-------

[](#license)

[![FOSSA Status](https://camo.githubusercontent.com/9286b803efc8fdfb9c9d260997b8f6c15df8d2ad9a34f419e07b9a7c4bc78db2/68747470733a2f2f6170702e666f7373612e636f6d2f6170692f70726f6a656374732f6769742532426769746875622e636f6d253246676f6472756f79692532466c61726176656c2d6964636172642d76616c696461746f722e7376673f747970653d6c61726765)](https://app.fossa.com/projects/git%2Bgithub.com%2Fgodruoyi%2Flaravel-idcard-validator?ref=badge_large)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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 ~195 days

Total

5

Last Release

1803d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5520e5d6782001b3417724a0d5942bb9bfc6885f5aac48d5e69891ef3240141d?d=identicon)[godruoyi](/maintainers/godruoyi)

---

Top Contributors

[![godruoyi](https://avatars.githubusercontent.com/u/16079222?v=4)](https://github.com/godruoyi "godruoyi (17 commits)")

---

Tags

idcardcheckidcardnumber-validationidcardocr-chinalaravellaravel-idcard-validatorlaravelidentitylaravel idcard

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/godruoyi-laravel-idcard-validator/health.svg)

```
[![Health](https://phpackages.com/badges/godruoyi-laravel-idcard-validator/health.svg)](https://phpackages.com/packages/godruoyi-laravel-idcard-validator)
```

###  Alternatives

[carsdotcom/laravel-json-schema

Json Schema validation for Laravel projects

1036.7k3](/packages/carsdotcom-laravel-json-schema)

PHPackages © 2026

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