PHPackages                             akawalko/respect-validation-rules - 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. akawalko/respect-validation-rules

ActiveLibrary

akawalko/respect-validation-rules
=================================

Custom rules for the most awesome validation engine ever created for PHP.

v1.0.1(2y ago)07MITPHPPHP ^8.0 || ^8.1 || ^8.2

Since Nov 20Pushed 2y ago1 watchersCompare

[ Source](https://github.com/akawalko/respect-validation-rules)[ Packagist](https://packagist.org/packages/akawalko/respect-validation-rules)[ RSS](/packages/akawalko-respect-validation-rules/feed)WikiDiscussions main Synced 1mo ago

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

respect-validation-rules
========================

[](#respect-validation-rules)

What is this
------------

[](#what-is-this)

This repository will be a set of additional rules for the brilliant data validation library called [Respect\\Validation](https://github.com/Respect/Validation "The most awesome validation engine ever created for PHP")

Install
-------

[](#install)

### Require php: &gt;= 8.0

[](#require-php--80)

```
composer require akawalko/respect-validation-rules

```

Usage
-----

[](#usage)

After installing the package in the place where you want to use my rules, you must use the autoloder and import classes from the namespace.

```
require_once 'vendor/autoload.php';

use Respect\Validation\Exceptions\NestedValidationException;
use Respect\Validation\Rules\AllOf;
use Respect\Validation\Validator as v;
use Respect\Validation\Factory;
```

To use my rules you need to overwrite the default factory so that it knows in which namespace to look for new rules.

```
Factory::setDefaultInstance(
    (new Factory())
        ->withRuleNamespace('RespectValidationRules\\Rules')
        ->withExceptionNamespace('RespectValidationRules\\Exceptions')
);
```

Rules
-----

[](#rules)

### DynamicAttr

[](#dynamicattr)

When you have an object that uses dynamic properties with the help of magic methods like \_\_get() and \_\_set() you can't use a rule **Attribute**. It will not work. The solution is my custom method **DynamicAttr**.

Let's look at this short example:

```
$dynamicObject = new ClassWithMagicMethods();
$dynamicObject->firstname = 'John Wesley';
$dynamicObject->lastname = 'Connor';
$dynamicObject->age = 36;

$validator = new AllOf(
    v::dynamicAttr(
        'firstname',
        v::stringType()
            ->alpha()
            ->length(2, 10)
    ),

    v::dynamicAttr(
        'lastname',
        v::stringType()
            ->length(null, 190)
        false // property can be undefined
    ),

    v::dynamicAttr(
        'age',
        v::intVal()
            ->min(18)
    )
);

try {
    $validator->assert($dynamicObject);
    echo "valid\n";
} catch (NestedValidationException $exception) {
    echo "not valid\n";
    print_r($exception->getMessages());
}
```

The full code of the example can be found here: [examples/example\_01.php](https://github.com/akawalko/respect-validation-rules/blob/main/examples/example_01.php)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

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

Total

2

Last Release

889d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8fca236fe992bd3222344ed9cb9296e25b3c3753dc18054d2175a5926c6be9a1?d=identicon)[akawalko](/maintainers/akawalko)

---

Top Contributors

[![akawalko](https://avatars.githubusercontent.com/u/7594428?v=4)](https://github.com/akawalko "akawalko (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/akawalko-respect-validation-rules/health.svg)

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

###  Alternatives

[league/openapi-psr7-validator

Validate PSR-7 messages against OpenAPI (3.0.2) specifications expressed in YAML or JSON

55615.9M69](/packages/league-openapi-psr7-validator)[davidepastore/slim-validation

A slim middleware for validation based on Respect/Validation

171223.7k3](/packages/davidepastore-slim-validation)[hkarlstrom/openapi-validation-middleware

PSR-7 and PSR-15 OpenAPI Validation Middleware

95198.8k1](/packages/hkarlstrom-openapi-validation-middleware)[awurth/slim-validation

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

65378.4k9](/packages/awurth-slim-validation)[macfja/redisearch

PHP Client for RediSearch

67154.9k1](/packages/macfja-redisearch)[lanlin/nylas-php

Nylas PHP SDK (api version 2.7)

28258.7k](/packages/lanlin-nylas-php)

PHPackages © 2026

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