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

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

danek/validator
===============

Flexible validation library with no dependencies.

012PHP

Since Aug 29Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/jDanek/validator)[ Packagist](https://packagist.org/packages/danek/validator)[ RSS](/packages/danek-validator/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

*Danek\\Validator* is a very small validation library, with the easiest and most usable API we could possibly create.

Install
-------

[](#install)

To easily include *Danek\\Validator* into your project, install it via [composer](https://getcomposer.org) using the command line:

```
composer require danek/validator
```

Small usage example
-------------------

[](#small-usage-example)

```
use Danek\Validator\Validator;

$v = new Validator;

$v->required('user.first_name')->lengthBetween(2, 50)->alpha();
$v->required('user.last_name')->lengthBetween(2, 50)->alpha();
$v->required('newsletter')->bool();

$result = $v->validate([
    'user' => [
        'first_name' => 'John',
        'last_name' => 'D',
    ],
    'newsletter' => true,
]);

$result->isValid(); // bool(false).
$result->getMessages();
/**
 * array(1) {
 *     ["user.last_name"]=> array(1) {
 *         ["Length::TOO_SHORT"]=> string(53) "last_name is too short and must be 2 characters long."
 *     }
 * }
 */
```

Functional features
-------------------

[](#functional-features)

- Validate an array of data
- Get an array of error messages
- Overwrite the default error messages on rules, or error messages on specific values
- Get the validated values of an array
- Validate different contexts (insert, update, etc.) inheriting validations of the default context
- Ability to extend the validator to add your own custom rules

Non functional features
-----------------------

[](#non-functional-features)

- Easy to write (IDE auto-completion for easy development)
- Easy to read (improves peer review)
- Ability to separate controller and view logic
- Zero dependencies

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1703182?v=4)[Jirka Daněk](/maintainers/jDanek)[@jDanek](https://github.com/jDanek)

---

Top Contributors

[![jDanek](https://avatars.githubusercontent.com/u/1703182?v=4)](https://github.com/jDanek "jDanek (10 commits)")

### Embed Badge

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

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

###  Alternatives

[marcosh/php-validation-dsl

A DSL for validating data in a functional fashion

483.9k](/packages/marcosh-php-validation-dsl)

PHPackages © 2026

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