PHPackages                             emonkak/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. emonkak/validation

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

emonkak/validation
==================

A type-based validation library

v1.0.1(5y ago)02.6kMITPHPPHP &gt;=7.1CI failing

Since Mar 5Pushed 5y ago1 watchersCompare

[ Source](https://github.com/emonkak/php-validation)[ Packagist](https://packagist.org/packages/emonkak/validation)[ RSS](/packages/emonkak-validation/feed)WikiDiscussions master Synced 1w ago

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

Emonkak\\Validation
===================

[](#emonkakvalidation)

[![Build Status](https://camo.githubusercontent.com/3b308cf686f788f9764e03528ea50bcac7c326b0efd5bbefb358c7f283960714/68747470733a2f2f7472617669732d63692e6f72672f656d6f6e6b616b2f7068702d76616c69646174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/emonkak/php-validation)[![Coverage Status](https://camo.githubusercontent.com/bcb55e90b6f970edd729fa7ea19f1a6e1d8d1668411ad9a1ce02efd72f8f667d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f656d6f6e6b616b2f7068702d76616c69646174696f6e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/emonkak/php-validation?branch=master)

Example
-------

[](#example)

```
use Emonkak\Validation\Types;
use Emonkak\Validation\Validator;

$validator = new Validator([
    'foo' => Types::oneOfType([Types::int(), Types::bool()]),
    'bar' => Types::string(),
    'baz' => Types::bool(),
    'qux' => Types::any(),
    'quux' => Types::arrayOf(Types::string()),
    'foobar' => Types::string()->isOptional(),
    'piyo' => Types::oneOf(['foo', 'bar']),
    'puyo' => Types::shape('Puyo', ['foo' => Types::string()]),
    'payo' => Types::dateTime(),
]);

$errors = $validator->validate([
    'foo' => 'foo',
    'bar' => '123',
    'baz' => 'true',
    'qux' => null,
    'quux' => ['1', '2'],
    'puyo' => ['foo' => 123],
    'payo' => '2000-01-01 00:00:00'
]);

foreach ($errors->getErrors() as $key => $errors) {
    echo $key, ': ', implode(' ', $errors), PHP_EOL;
}

// OUTPUT:
// foo: The property `foo` must be `integer|boolean`, got `string`.
// qux: The property `qux` must be `any`, got `NULL`.
// piyo: The property `piyo` must be `"foo"|"bar"`, got `NULL`.
// puyo.foo: The property `puyo.foo` must be `string`, got `integer`.
```

Licence
-------

[](#licence)

MIT Licence

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Total

2

Last Release

2175d ago

PHP version history (2 changes)v1.0.0PHP &gt;=5.6

v1.0.1PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/482d690ac653e05c9f5625e0f5f6e71b55e77646ab722bbcfdfbd26bf3c8d86b?d=identicon)[emonkak](/maintainers/emonkak)

---

Top Contributors

[![emonkak](https://avatars.githubusercontent.com/u/188621?v=4)](https://github.com/emonkak "emonkak (20 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/emonkak-validation/health.svg)

```
[![Health](https://phpackages.com/badges/emonkak-validation/health.svg)](https://phpackages.com/packages/emonkak-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)
