PHPackages                             phpviet/validation - 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. phpviet/validation

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

phpviet/validation
==================

Thư viện hổ trợ kiểm tra dữ liệu đặc thù trong nước

1.0.2(6y ago)72.3k6[1 issues](https://github.com/phpviet/validation/issues)[1 PRs](https://github.com/phpviet/validation/pulls)3MITPHPPHP ^7.1

Since May 23Pushed 4y ago2 watchersCompare

[ Source](https://github.com/phpviet/validation)[ Packagist](https://packagist.org/packages/phpviet/validation)[ Docs](https://github.com/phpviet/validation)[ RSS](/packages/phpviet-validation/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (3)

 [ ![](https://avatars0.githubusercontent.com/u/50674062) ](https://github.com/phpviet)

Validation
==========

[](#validation)

 [![Latest version](https://camo.githubusercontent.com/6770d3545da335ffda90ae8df8899425e5072ed4812514cb1a758bf0aa5602c1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706870766965742f76616c69646174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpviet/validation) [![Build status](https://camo.githubusercontent.com/dbd5b7ed1dbfa3b95c2a763399c2796d5e2245c8e5744a534a1306b61b99e22f/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f706870766965742f76616c69646174696f6e2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/phpviet/validation) [![Quantity score](https://camo.githubusercontent.com/ce030dcd68802d31410c05b5048a67027ed11c7f8001d6dc2d84cda396422b8f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f706870766965742f76616c69646174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/phpviet/validation) [![StyleCI](https://camo.githubusercontent.com/76aff8fe6eca35734b9d20c10384147efb85b7c12d5591f6d66f6b2066250a81/68747470733a2f2f7374796c6563692e696f2f7265706f732f3138373036333733312f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/187063731) [![Total download](https://camo.githubusercontent.com/72ec1207e3d3a904e7d6b76658f5bf1b61e35a67c5b71c927a23eeed514ce2e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706870766965742f76616c69646174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpviet/validation) [![License](https://camo.githubusercontent.com/755b31c2e53121c3a8acbdbcea0bb24b15cbee798614a46355906664846d6f80/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f706870766965742f76616c69646174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpviet/validation)

Thông tin
---------

[](#thông-tin)

Thư viện hổ trợ kiểm tra các kiểu dữ liệu đặc thù trong nước ta được phát triển trên nền tảng [Respect/Validation](https://github.com/respect/validation).

Cài đặt
-------

[](#cài-đặt)

Cài đặt PHP Việt Validation thông qua [Composer](https://getcomposer.org):

```
composer require phpviet/validation
```

Cách sử dụng
------------

[](#cách-sử-dụng)

### Tích hợp sẵn trên các framework phổ biến hiện tại

[](#tích-hợp-sẵn-trên-các-framework-phổ-biến-hiện-tại)

- [`Laravel`](https://github.com/phpviet/laravel-validation)
- [`Symfony`](https://github.com/phpviet/symfony-validation)
- [`Yii`](https://github.com/phpviet/yii-validation)

hoặc nếu bạn muốn sử dụng không dựa trên framework thì tiếp tục xem tiếp.

### Các kiểu dữ liệu được hổ trợ kiểm tra hiện tại

[](#các-kiểu-dữ-liệu-được-hổ-trợ-kiểm-tra-hiện-tại)

- [`Số điện thoại di động`](#S%E1%BB%91-%C4%91i%E1%BB%87n-tho%E1%BA%A1i-di-%C4%91%E1%BB%99ng)
- [`Số điện thoại bàn`](#S%E1%BB%91-%C4%91i%E1%BB%87n-tho%E1%BA%A1i-b%C3%A0n)
- [`Thẻ căn cước / chứng minh thư`](#Th%E1%BA%BB-c%C4%83n-c%C6%B0%E1%BB%9Bc-/-ch%E1%BB%A9ng-minh-th%C6%B0)
- [`Địa chỉ IP`](#%C4%90%E1%BB%8Ba-ch%E1%BB%89-IP)

### Số điện thoại di động

[](#số-điện-thoại-di-động)

```
use PHPViet\Validation\Validator;

$input = 'số điện thoại';

var_dump(Validator::mobileVN()->validate($input)); // trả về true hoặc false tương đương với dữ liệu hợp lệ hoặc không.

var_dump(Validator::mobileVN()->assert($input)); // throw exception nếu dữ liệu không hợp lệ.
```

### Số điện thoại bàn

[](#số-điện-thoại-bàn)

```
use PHPViet\Validation\Validator;

$input = 'số điện thoại';

var_dump(Validator::landLineVN()->validate($input)); // trả về true hoặc false tương đương với dữ liệu hợp lệ hoặc không.

var_dump(Validator::landLineVN()->assert($input)); // throw exception nếu dữ liệu không hợp lệ.
```

### Thẻ căn cước / chứng minh thư

[](#thẻ-căn-cước--chứng-minh-thư)

```
use PHPViet\Validation\Validator;

$input = 'Số thẻ căn cước hoặc chứng minh thư';

var_dump(Validator::idVN()->validate($input)); // trả về true hoặc false tương đương với dữ liệu hợp lệ hoặc không.

var_dump(Validator::idVN()->assert($input)); // throw exception nếu dữ liệu không hợp lệ.
```

### Địa chỉ IP

[](#địa-chỉ-ip)

```
use PHPViet\Validation\Validator;

$input = 'ipv4 hoặc ipv6';

var_dump(Validator::ipVN()->validate($input)); // trả về true hoặc false tương đương với dữ liệu hợp lệ hoặc không.

var_dump(Validator::ipVN()->assert($input)); // throw exception nếu dữ liệu không hợp lệ.

// chỉ kiểm tra ipv4

var_dump(Validator::ipVN(4)->validate($input)); // trả về true hoặc false tương đương với dữ liệu hợp lệ hoặc không.

var_dump(Validator::ipVN(4)->assert($input)); // throw exception nếu dữ liệu không hợp lệ.

// chỉ kiểm tra ipv6

var_dump(Validator::ipVN(6)->validate($input)); // trả về true hoặc false tương đương với dữ liệu hợp lệ hoặc không.

var_dump(Validator::ipVN(6)->assert($input)); // throw exception nếu dữ liệu không hợp lệ.
```

Mở rộng
-------

[](#mở-rộng)

Do thư viện được phát trên nền tảng [Respect/Validation](https://github.com/respect/validation) nên bạn có thể sử dụng toàn bộ tính năng kế thừa từ nó xem thêm tại [đây](https://respect-validation.readthedocs.io/en/1.1/).

Dành cho nhà phát triển
-----------------------

[](#dành-cho-nhà-phát-triển)

Nếu như bạn cảm thấy các kiểu kiểm tra dữ liệu bên trên vẫn chưa đủ đối với thị trường trong nước và bạn muốn đóng góp để phát triển chung, chúng tôi rất hoan nghênh! Hãy tạo các `issue` để đóng góp ý tưởng cho phiên bản kế tiếp hoặc tạo `PR`để đóng góp thêm các kiểu kiểm tra dữ liệu còn thiếu sót. Cảm ơn!

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

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

Total

3

Last Release

2541d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8901d64a1059726b851dbdd91463ad1d3169f9dba6a2dcff11d05f97d9bccaea?d=identicon)[vuongxuongminh](/maintainers/vuongxuongminh)

---

Top Contributors

[![vuongxuongminh](https://avatars.githubusercontent.com/u/38932626?v=4)](https://github.com/vuongxuongminh "vuongxuongminh (37 commits)")

---

Tags

phpvietvalidationvietnamesevalidationphpviet

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phpviet-validation/health.svg)

```
[![Health](https://phpackages.com/badges/phpviet-validation/health.svg)](https://phpackages.com/packages/phpviet-validation)
```

###  Alternatives

[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M107](/packages/propaganistas-laravel-phone)[opis/json-schema

Json Schema Validator for PHP

64236.9M186](/packages/opis-json-schema)[giggsey/libphonenumber-for-php-lite

A lite version of giggsey/libphonenumber-for-php, which is a PHP Port of Google's libphonenumber

8412.9M47](/packages/giggsey-libphonenumber-for-php-lite)[awurth/slim-validation

A wrapper around the respect/validation PHP validation library for easier error handling and display

65378.4k9](/packages/awurth-slim-validation)[progsmile/request-validator

Simple PHP Request Validator

33113.3k1](/packages/progsmile-request-validator)

PHPackages © 2026

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