PHPackages                             paysera/lib-plugin-data-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. paysera/lib-plugin-data-validation

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

paysera/lib-plugin-data-validation
==================================

Library for iterable input validation

0.2.0(2y ago)03.7k↓50%1GPL-3.0PHPPHP &gt;=7.4

Since Mar 11Pushed 2y agoCompare

[ Source](https://github.com/enigma-tm/lib-plugin-data-validation)[ Packagist](https://packagist.org/packages/paysera/lib-plugin-data-validation)[ RSS](/packages/paysera-lib-plugin-data-validation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

Data Validator
==============

[](#data-validator)

This library is crafted for validating array-type input data, making it ideal for validating form submissions and similar tasks.

We've drawn inspiration from a [particular library](https://github.com/pdscopes/php-form-validator), but due to specific requirements, we couldn't integrate it directly. Hence, this package represents a tailored version tailored to suit our specific needs.

Not entire code of the original library was taken for this package. That's why the package does not contain many useful validation rules and code that handle them. Feel free to copy and adapt absent code if you need.

Basic usage
===========

[](#basic-usage)

```
namespace '...';

use Paysera\DataValidator\Validator\AbstractValidator;

class SomeValidator extends AbstractValidator
{
    public function __construct(RepositoryInterface $repository /* dependencies here */)
    {
        parent::__construct();

        $rule = new EntityExists($repository);
        $this->addRule($rule);
        $this->setRuleMessage($rule->getName(), 'error message for entity-exists rule');

        // for customisation of error for specific fields
        // you can use kind of MessageRepository here as a dependency
        $this->setAttributeMessage('field_name', 'custom_error_this_field');
    }
}
```

Then:

```
$someValidator = new SomeValidator(/*dependencies here*/);

$rules = [
    'field1' => 'entity-exists|other_rules:with_parameters',
];

if (!$someValidator->validate($this->request->post /* or any other array with data */)) {
    $errors = $someValidator->getProcessedErrors();
}

/*
 * 'field' => [
 *     'entity-exists' => 'error message for entity-exists validator rule',
 *     'other_rules' => 'error message for other rules',
 * ]
 */
```

You can use placeholders for messages:

```
$this->setRuleMessage('entity-exists', 'Order status with ID=:id must exist');
// or
$this->setAttributeMessage('specific_field', 'Order status with ID=:id must exist');
```

In this case, the placeholder will be replaced by the value of the field being checked

Adding new Validation Rules
---------------------------

[](#adding-new-validation-rules)

You have to create new class with CamelCase rule name ('entity-exists' =&gt; EntityExists)

You have to set the `$name` property, override the `__construct` method if you need some specific dependencies and then implement the `validate` method (because it is the abstract one).

Investigate the `EntityExists` class and the `AbstractValidatorTest` test as an examples of rules and their usage.

As mentioned above, you can take the code from the original library and use it here by adapting it. In particular, the validation rules code. Actually, it is strongly recommend to do in such way.

Testing
=======

[](#testing)

```
bash run_tests.sh

```

or manually:

```
docker build -t lib_plugin_data_validatior_tests -f $PWD/Dockerfile $PWD
docker run -it -v $PWD:/var/www -w /var/www lib_plugin_data_validatior_tests composer i
docker run -it -v $PWD:/var/www -w /var/www lib_plugin_data_validatior_tests composer run phpunit

```

Tests debugging
===============

[](#tests-debugging)

After building the `lib_plugin_data_validatior_tests` container you can use it for running and debugging tests under IDE

Setting debugging in the PHPStorm under Ubuntu example:
-------------------------------------------------------

[](#setting-debugging-in-the-phpstorm-under-ubuntu-example)

### Create an interpreter

[](#create-an-interpreter)

[![Screenshot of error in Flare](./doc/screenshots/interpreter_add.png)](./doc/screenshots/interpreter_add.png)

[![Screenshot of error in Flare](./doc/screenshots/interpreter_selection.png)](./doc/screenshots/interpreter_selection.png)

[![Screenshot of error in Flare](./doc/screenshots/interpreter_created.png)](./doc/screenshots/interpreter_created.png)

### Configure the interpreter and files mapping

[](#configure-the-interpreter-and-files-mapping)

[![Screenshot of error in Flare](./doc/screenshots/interpreter_configuration.png)](./doc/screenshots/interpreter_configuration.png)

### Create an endpoint for running tests

[](#create-an-endpoint-for-running-tests)

[![Screenshot of error in Flare](./doc/screenshots/tests_endpoint.png)](./doc/screenshots/tests_endpoint.png)

### Add a test framework

[](#add-a-test-framework)

[![Screenshot of error in Flare](./doc/screenshots/xdebug_test_framework_add.png)](./doc/screenshots/xdebug_test_framework_add.png)[![Screenshot of error in Flare](./doc/screenshots/xdebug_test_framework_configuration.png)](./doc/screenshots/xdebug_test_framework_configuration.png)

Enjoy!
------

[](#enjoy)

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 89.3% 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

Unknown

Total

1

Last Release

798d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9d385187c2b529d5c1189dfc3763972f76738d24293593ff3db876fff82321db?d=identicon)[paysera.com](/maintainers/paysera.com)

---

Top Contributors

[![oleksandr-gribiennikov-paysera](https://avatars.githubusercontent.com/u/148878964?v=4)](https://github.com/oleksandr-gribiennikov-paysera "oleksandr-gribiennikov-paysera (25 commits)")[![alexanderzaiets-paysera](https://avatars.githubusercontent.com/u/101864629?v=4)](https://github.com/alexanderzaiets-paysera "alexanderzaiets-paysera (3 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/paysera-lib-plugin-data-validation/health.svg)

```
[![Health](https://phpackages.com/badges/paysera-lib-plugin-data-validation/health.svg)](https://phpackages.com/packages/paysera-lib-plugin-data-validation)
```

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