PHPackages                             arefshojaei/class-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. arefshojaei/class-validator

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

arefshojaei/class-validator
===========================

PHP Class validator ( Attribute base ) library

1.4.4(2mo ago)0201MITPHPPHP ^8.2

Since Apr 23Pushed 2mo agoCompare

[ Source](https://github.com/ArefShojaei/Class-validator)[ Packagist](https://packagist.org/packages/arefshojaei/class-validator)[ RSS](/packages/arefshojaei-class-validator/feed)WikiDiscussions main Synced 1w ago

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

🛡️ Class Validator for PHP
==========================

[](#️-class-validator-for-php)

 A lightweight, powerful, and modern PHP 8.2+ validation library that uses **Attributes** to define validation rules directly inside your classes.

[![PHP Version](https://camo.githubusercontent.com/633e459384cbbe6af9209a0df1db4bfaf9b813e68645fbc230c0bc7073b07354/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382532422d626c75652e737667)](https://php.net)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![Packagist](https://camo.githubusercontent.com/4f2d456f09094ccf912f61107ef9159af026b590bf0f3b1352d21c6d67132f87/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5061636b61676973742d436c6173732d2d56616c696461746f722d6f72616e67652e737667)](https://packagist.org/packages/arefshojaei/class-validator)

---

✨ Features
----------

[](#-features)

- 🏷️ Attribute-based validation using native PHP 8 attributes
- 🧩 Validate entire objects and class properties
- 📝 Custom error messages for every validation rule
- ⚡ Static validation methods for quick checks
- 📦 Simple Composer installation
- 🪶 Lightweight with zero unnecessary dependencies
- 🔒 Strongly typed and modern PHP syntax
- 🛠️ Easy to extend with custom validation rules

---

📥 Installation
--------------

[](#-installation)

### Install using Composer

[](#install-using-composer)

```
composer require arefshojaei/class-validator
```

### Clone from GitHub

[](#clone-from-github)

```
git clone https://github.com/ArefShojaei/Class-validator.git
cd Class-validator
```

---

🚀 Quick Start
-------------

[](#-quick-start)

### 1. Create a DTO or Entity with Validation Attributes

[](#1-create-a-dto-or-entity-with-validation-attributes)

```
