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

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

azolee/validator
================

A Laravel like framework agnostic Validation package for PHP8.2

v3.2.0(7mo ago)10731MITPHPPHP ^8.2

Since Oct 16Pushed 7mo ago2 watchersCompare

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

READMEChangelog (10)Dependencies (1)Versions (23)Used By (0)

The Laravel-like data validator for PHP
=======================================

[](#the-laravel-like-data-validator-for-php)

[![Latest Version](https://camo.githubusercontent.com/ffe9a92279cead16ee3dd5c7948f754247e5d024bd7a346a87d3b9793db49d62/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617a6f6c65652f76616c696461746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/azolee/validator)

The Laravel-like Validator is a PHP validation library designed to help you validate data structures with ease. It supports various validation rules, custom rules, and nested data validation.

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require azolee/validator
```

Usage
-----

[](#usage)

For a complete list of available validation rules, please refer to the [Validation Rules](docs/Rules.md) document.

### Basic Usage

[](#basic-usage)

To use the validator, you need to define your validation rules and the data to be validated. Then, call the `Validator::make` method.

```
use Azolee\Validator\Validator;

$validationRules = [
    'user.name' => 'string',
    'user.age' => 'numeric',
    'user.email' => ['email', 'not_null'],
    'user.website' => ['url'],
    'user.password' => ['password:ulds', 'min:8'],
    'user.password_confirmation' => ['same:user.password'],
    'user.is_active' => ['boolean', 'not_null'],
    'address' => 'array',
    'address.city' => 'string',
    'address.street' => ['string', 'different:address.city', 'different:address.street2', 'different:address.no'],
    'address.street2' => 'not_null',
    'address.no' => 'string',
    'images.*.url' => 'string',
    'images.*.role' => ['string', 'in:profile_photo,album_photo'],
];

$dataToValidate = [
    'user' => [
        'name' => 'John Doe',
        'email' => 'user@email.com',
        'password' => 'SecretPasswd#1',
        'password_confirmation' => 'secret',
        'website' => 'https://github.com',
        'age' => 30,
        'is_active' => true,
    ],
    'address' => [
        'city' => 'New York',
        'street' => 'First Avenue',
        'street2' => '',
        'no' => '52A',
    ],
    'images' => [
        [
            'url' => 'image1.jpg'
            'role' => 'profile_photo',
        ],
        [
            'url' => 'image2.jpg'
            'role' => 'album_photo',
            'description' => 'This is a photo of me.',
        ],
    ],
];

$result = Validator::make($validationRules, $dataToValidate);

if ($result->isFailed()) {
    echo "Validation failed!";
    print_r($result->getFailedRules());
} else {
    echo "Validation passed!";
}
```

### Custom Rules

[](#custom-rules)

You can also define custom validation rules using closures.

```
$validationRules = [
    'user.name' => [
        function ($data) {
            return $data !== 'John Doe';
        },
        'string',
    ],
];

$dataToValidate = [
    'user' => [
        'name' => 'John Smith'
    ],
];

$result = Validator::make($validationRules, $dataToValidate);

if ($result->isFailed()) {
    echo "Validation failed!";
    print_r($result->getFailedRules());
} else {
    echo "Validation passed!";
}
```

### Exception Handling

[](#exception-handling)

The validator can throw exceptions for invalid rules or data if the `silent` parameter is set to `false`.

```
use Azolee\Validator\Exceptions\InvalidValidationRule;
use Azolee\Validator\Exceptions\ValidationException;

try {
    $validationRules = [
        'name' => 123, // Invalid rule
    ];
    $dataToValidate = [
        'name' => 'John Doe',
    ];

    Validator::config(['silent' => false])->make($validationRules, $dataToValidate);
} catch (InvalidValidationRule $e) {
    echo "Caught an InvalidValidationRule exception: " . $e->getMessage();
} catch (ValidationException $e) {
    echo "Caught a ValidationException: " . $e->getMessage();
}
```

Additional Examples
-------------------

[](#additional-examples)

For more detailed examples, please refer to the following documents:

- [Simple Examples](docs/SimpleExamples.md)
- [Complex Examples](docs/ComplexExamples.md)

Testing
-------

[](#testing)

To run the tests, use PHPUnit:

```
vendor/bin/phpunit
```

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance62

Regular maintenance activity

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

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

Recently: every ~55 days

Total

21

Last Release

235d ago

Major Versions

v1.2.0 → v2.0.02024-10-22

v2.9.0 → v3.0.02025-02-22

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/835466?v=4)[Zoli](/maintainers/azolee)[@azolee](https://github.com/azolee)

---

Top Contributors

[![azolee](https://avatars.githubusercontent.com/u/835466?v=4)](https://github.com/azolee "azolee (65 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/azolee-validator/health.svg)

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

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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