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

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

threeleaf/validation-engine
===========================

A Laravel Eloquent Model for managing dynamic validation engine rules.

2.0.0(4mo ago)0433GPL-3.0+PHPPHP &gt;=8.2CI passing

Since Oct 29Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/ThreeLeaf-com/ValidationEngine)[ Packagist](https://packagist.org/packages/threeleaf/validation-engine)[ RSS](/packages/threeleaf-validation-engine/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (11)Used By (0)

ThreeLeaf.com Validation Engine
===============================

[](#threeleafcom-validation-engine)

**A Laravel library for managing dynamic validation rules and configurations.**

**Compatible with Laravel 12 and PHP 8.2+**

Overview
--------

[](#overview)

The `ValidationEngine` library provides a robust solution for managing validation rules and configurations in a dynamic manner. It allows you to define validators that group multiple rules and apply them based on various criteria, such as time and status. This library is particularly useful for scenarios where validation logic needs to be customized or adjusted without directly modifying the codebase.

ValidationEngine
================

[](#validationengine)

[![Latest Stable Version](https://camo.githubusercontent.com/95c9bfee2bf5fff3fe1bd4a7c6a151bda91aff7c84c0b8aa525d84005356537c/68747470733a2f2f706f7365722e707567782e6f72672f74687265656c6561662f76616c69646174696f6e2d656e67696e652f762f737461626c65)](https://packagist.org/packages/threeleaf/validation-engine)[![GitHub last commit](https://camo.githubusercontent.com/a992cc26260b09b0a7b054921fd84b4fa5a185989c0d21221aa77abe1a83af85/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f54687265654c6561662d636f6d2f56616c69646174696f6e456e67696e65)](https://github.com/ThreeLeaf-com/ValidationEngine/commits/main)[![Build Status](https://github.com/ThreeLeaf-com/ValidationEngine/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/ThreeLeaf-com/ValidationEngine/actions)[![Coverage](./public/images/coverage-badge.svg)](./public/images/coverage-badge.svg)[![PHP Version](https://camo.githubusercontent.com/66121acf8fc0a83979590bb27b5c667a9a16d23057eeed4edb3faa626bb08711/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f74687265656c6561662f76616c69646174696f6e2d656e67696e65)](https://packagist.org/packages/threeleaf/validation-engine)[![License](https://camo.githubusercontent.com/38ff2b0814dcd009659ccb3735f670ea816c9d3820badc48cade866760cb6c5a/68747470733a2f2f706f7365722e707567782e6f72672f74687265656c6561662f76616c69646174696f6e2d656e67696e652f6c6963656e7365)](https://packagist.org/packages/threeleaf/validation-engine)[![Total Downloads](https://camo.githubusercontent.com/1594ae70b6030f6a3e8f27911611cf037d0019bf93eea95f87104131d5177aa2/68747470733a2f2f706f7365722e707567782e6f72672f74687265656c6561662f76616c69646174696f6e2d656e67696e652f646f776e6c6f616473)](https://packagist.org/packages/threeleaf/validation-engine)

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

[](#installation)

Install the library via Composer:

```
composer require threeleaf/validation-engine
```

Run the migrations to create the necessary tables:

```
php artisan migrate
```

Usage
-----

[](#usage)

### Setting Up and Use Validators

[](#setting-up-and-use-validators)

To create a new validator and associate rules with it, use the `Validator` and `Rule` models:

```
use Illuminate\Container\Container;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator as LaravelValidator;
use Tests\Feature\TestCase;
use ThreeLeaf\ValidationEngine\Enums\ActiveStatus;
use ThreeLeaf\ValidationEngine\Models\Rule;
use ThreeLeaf\ValidationEngine\Models\Validator;
use ThreeLeaf\ValidationEngine\Models\ValidatorRule;
use ThreeLeaf\ValidationEngine\Rules\EnumRule;

/* Create a new validator */
$newValidator = Validator::create([
    'name' => 'StateAndTimeValidator',
    'description' => 'Validates state and checks time for Monday business hours.',
    'active_status' => ActiveStatus::ACTIVE,
]);

/* Create a rule */
$newRule = Rule::create([
    'attribute' => 'active_status',
    'rule_type' => EnumRule::class,
    'parameters' => json_encode([
        'enumClass' => 'ThreeLeaf\\ValidationEngine\\Enums\\ActiveStatus',
        'allowedValues' => [ActiveStatus::ACTIVE],
    ]),
]);

/* Associate the rule with the validator */
ValidatorRule::create([
    'validator_id' => $newValidator->validator_id,
    'rule_id' => $newRule->rule_id,
    'order_number' => 1,
    'active_status' => ActiveStatus::INACTIVE,
]);

/* Retrieve the validator */
$validator = Validator::where('name', 'StateAndTimeValidator')->first();

/* Extract the rule */
$rule = $validator->rules->first->get();

/* Retrieve the rule parameters */
$parameters = json_decode($rule->parameters, true);
$compiledRules = [
    $rule->attribute => [Container::getInstance()->makeWith(EnumRule::class, $parameters)],
];

/* Serialize the value you want to validate. */
$data = ['active_status' => ActiveStatus::ACTIVE->value];

/* Create the validator */
$validator = LaravelValidator::make($data, $compiledRules);

if ($validator->passes()) {
    Log::info('Success!');
}
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please submit a pull request or open an issue to discuss your ideas.

License
-------

[](#license)

This library is open-sourced software licensed under the [GPL-3.0+](https://www.gnu.org/licenses/gpl-3.0.html).

Miscellaneous
-------------

[](#miscellaneous)

### OpenApi Documentation

[](#openapi-documentation)

OpenAPI documentation can be generated within the application using the command:

```
php util/generate-swagger.php
```

### Generate Coverage Badge

[](#generate-coverage-badge)

After running the tests with code coverage, run the following script to update the coverage badge:

```
php util/generate-coverage-badge.php
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance75

Regular maintenance activity

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.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 ~47 days

Recently: every ~80 days

Total

10

Last Release

137d ago

Major Versions

1.0.8 → 2.0.02026-01-01

PHP version history (2 changes)1.0.0PHP &gt;=8.1

2.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5519679?v=4)[John A. Marsh](/maintainers/JohnZavyn)[@JohnZavyn](https://github.com/JohnZavyn)

---

Top Contributors

[![JohnZavyn](https://avatars.githubusercontent.com/u/5519679?v=4)](https://github.com/JohnZavyn "JohnZavyn (59 commits)")[![john-marsh-redcat](https://avatars.githubusercontent.com/u/212599783?v=4)](https://github.com/john-marsh-redcat "john-marsh-redcat (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

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