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 8mo ago1 watchersCompare

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

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

Maintenance42

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity13

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://www.gravatar.com/avatar/47f53de5bcf5b58629ade7d7f49cfde9e1be9d0031a4b94fad01a803d98a7de7?d=identicon)[jDanek](/maintainers/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

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