PHPackages                             district5/validatorgroup - 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. district5/validatorgroup

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

district5/validatorgroup
========================

District5 Validator Group Library

2.0.1(11mo ago)0123mitPHPPHP &gt;=8.1.0CI passing

Since May 26Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/district-5/php-validatorgroup)[ Packagist](https://packagist.org/packages/district5/validatorgroup)[ Docs](https://bitbucket.district5.co.uk/projects/D5LIBS/repos/validatorgroup/browse)[ RSS](/packages/district5-validatorgroup/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (6)Used By (0)

PHP ValidatorGroup
==================

[](#php-validatorgroup)

Validator group for validating form and json body data.

Usage
-----

[](#usage)

### Validation Group

[](#validation-group)

Create a class and extend `\District5\ValidatorGroup\Group`, adding fields to be validated against.

```
/**
 * Creates a new instance of AuthValidationGroup
 */
public function __construct()
{
    $stringTrim = new StringTrim();

    $this->addField('username', [new StringLength(['min' => 4, 'max' => 254])], [$stringTrim], true);
    $this->addField('password', [new StringLength(['min' => 6, 'max' => 64])], [$stringTrim], true);
    $this->addField('device_id', [new StringLength(['min' => 6, 'max' => 64])], [], true);
}
```

### Validating

[](#validating)

This can then be used in a route, with a handler, for example with the following code:

```
$request = $app->request();

$vg = new \Project\Validate\Group\AuthAuthValidationGroup();
```

The validation group can be used to validate against any custom data with the correct handler; the library as a default ships with a JSON handler:

```
$handler = new \District5\ValidatorGroup\Handler\JSON($request->getBody());
$valid = $vg->isValid($handler);
```

### Custom Handlers

[](#custom-handlers)

You can create your own handlers by implementing the `\District5\ValidationGroup\Handler\HandlerInterface` and passing this into the `ValidationGroup`.

### Errors

[](#errors)

If validation failed, the validation group will give you some hint as to why it failed by calling:

```
$vg->getLastErrorMessage();
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance52

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity76

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

Total

5

Last Release

340d ago

Major Versions

1.3.3 → 2.0.02024-03-25

PHP version history (2 changes)1.0.2PHP &gt;=5.4.0

2.0.0PHP &gt;=8.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5de4b9a90eadf6b595e1b5efc802683f2358da5661c616820b90c922f8aa8e05?d=identicon)[rogerthomas84](/maintainers/rogerthomas84)

![](https://www.gravatar.com/avatar/c566343bfe6b0a3602622dd1def882992f10ff114b6a95ffb000da2ba9e22578?d=identicon)[mark-morgan](/maintainers/mark-morgan)

---

Top Contributors

[![mark-morgan](https://avatars.githubusercontent.com/u/1934581?v=4)](https://github.com/mark-morgan "mark-morgan (25 commits)")

---

Tags

phpdistrict5validator group

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/district5-validatorgroup/health.svg)

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

PHPackages © 2026

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