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

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

oihana/php-validation
=====================

The Oihana PHP Validation library

00PHPCI passing

Since Jun 20Pushed todayCompare

[ Source](https://github.com/BcommeBois/oihana-php-validation)[ Packagist](https://packagist.org/packages/oihana/php-validation)[ RSS](/packages/oihana-php-validation/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Oihana PHP - Validation
=======================

[](#oihana-php---validation)

[![Oihana PHP Validation](https://raw.githubusercontent.com/BcommeBois/oihana-php-validation/main/assets/images/oihana-php-validation-logo-inline-512x160.png)](https://raw.githubusercontent.com/BcommeBois/oihana-php-validation/main/assets/images/oihana-php-validation-logo-inline-512x160.png)

Composable validation rules and helpers for PHP 8.4+, built on [Somnambulist Validation](https://github.com/somnambulist-tech/validation).

[![Latest Version](https://camo.githubusercontent.com/05bbb0eb87664f9420fdb6df15cffa8a85d96e3afcb5a4d231730ae0602777c5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6968616e612f7068702d76616c69646174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oihana/php-validation)
[![Total Downloads](https://camo.githubusercontent.com/25704bc3c89da886ea38f5b3cd447d22602fc09987b86c07194d544f20130cfc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6968616e612f7068702d76616c69646174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oihana/php-validation)
[![License](https://camo.githubusercontent.com/c31c53f67037cb7f8a7c8be3347fb2a1da00d8cc22133696f2828dfa5857ffe9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6f6968616e612f7068702d76616c69646174696f6e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

📚 Documentation
---------------

[](#-documentation)

User guides (FR + EN), with narrative explanations and examples:

🇬🇧 **[English documentation](wiki/en/README.md)**🇫🇷 **[Documentation française](wiki/fr/README.md)**Getting started, rules, helpers, ISO 8601, geo &amp; i18n, model-aware rules, custom rules, testing.Démarrage, règles, helpers, ISO 8601, géo &amp; i18n, règles liées aux modèles, règles sur mesure, tests.Auto-generated API reference (phpDocumentor):
👉

🧠 What is it?
-------------

[](#-what-is-it)

This package extends [Somnambulist Validation](https://github.com/somnambulist-tech/validation)with a curated set of reusable, strongly-typed **rules** and expressive **helper functions**. Each rule is a small, focused, tested class you register with the validation factory; each helper builds a rule expression string fluently.

```
use Somnambulist\Components\Validation\Factory;
use oihana\validations\rules\ISO8601DateRule;

use function oihana\validations\rules\helpers\between;

$factory = new Factory();
$factory->addRule( 'iso8601_date', new ISO8601DateRule() );

$validation = $factory->validate
(
    [ 'birthDate' => '1990-05-01', 'age' => 34 ],
    [
        'birthDate' => 'required|iso8601_date',
        'age'       => 'required|' . between( 0, 120 ), // "between:0,120"
    ]
);

$validation->passes(); // true
```

🚀 Features
----------

[](#-features)

- 🔢 Comparison &amp; range rules — `EqualRule`, `GreaterThanRule`, `LessThanRule`, `RangeRule`.
- 📅 ISO 8601 date, datetime &amp; duration rules — `ISO8601DateRule`, `ISO8601DateTimeRule`, `ISO8601DurationRule`.
- 🌍 Geo &amp; i18n rules — `LatitudeRule`, `LongitudeRule`, `ElevationRule`, `I18nRule`, `PostalCodeRule`.
- 🗄️ Model-aware rules — `ExistModelRule`, `UniqueModelRule`, `ConstantsRule`.
- 🔐 Auth rules — `EffectRule`, `JWTAlgorithmRule`; HTTP — `HttpMethodRule`.
- 🧰 Expressive rule helpers — `between()`, `requiredIf()`, `digitsBetween()`, `arrayMustHaveKeys()`, and more.
- 🧪 Full unit-test coverage ensuring reliability and maintainability.

💡 Designed to be lightweight, testable, and compatible with any PHP 8.4+ project.

📦 Installation
--------------

[](#-installation)

> **Requires [PHP 8.4+](https://php.net/releases/)**

Install via [Composer](https://getcomposer.org):

```
composer require oihana/php-validation
```

✅ Tests &amp; coverage
----------------------

[](#-tests--coverage)

Run the full unit-test suite (PHPUnit, strict mode):

```
composer test
```

Run a single test case:

```
./vendor/bin/phpunit --filter ISO8601DateRuleTest
```

Measure coverage (requires Xdebug or PCOV):

```
composer coverage        # text + Clover + HTML under build/coverage/
composer coverage:md     # readable Markdown summary (build/coverage/COVERAGE.md)
```

The suite runs in **strict mode** and targets **100% line coverage**.

🧾 License
---------

[](#-license)

This project is licensed under the [Mozilla Public License 2.0 (MPL-2.0)](https://www.mozilla.org/en-US/MPL/2.0/).

👤 About the author
------------------

[](#-about-the-author)

- Author : Marc ALCARAZ (aka eKameleon)
- Mail :
- Website :

🛠️ Generate the Documentation
-----------------------------

[](#️-generate-the-documentation)

We use [phpDocumentor](https://phpdoc.org/) to generate the documentation into the ./docs folder.

### Usage

[](#usage)

Run the command :

```
composer doc
```

🔗 Related packages
------------------

[](#-related-packages)

- [oihana/php-models](https://github.com/BcommeBois/oihana-php-models) – document/PDO models used by the model-aware rules.
- [oihana/php-standards](https://github.com/BcommeBois/oihana-php-standards) – ISO standards (ISO 8601, ISO 3166) used by the date and postal rules.
- [oihana/php-enums](https://github.com/BcommeBois/oihana-php-enums) – a collection of strongly-typed constant enumerations for PHP.
- [oihana/php-core](https://github.com/BcommeBois/oihana-php-core) – core helpers and utilities used by this library.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

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/d234506e51778dd3d1d61b6c2af6f294ff963651b4aa509b595d3d2a77b7d89b?d=identicon)[ooop](/maintainers/ooop)

---

Top Contributors

[![ekameleon](https://avatars.githubusercontent.com/u/749032?v=4)](https://github.com/ekameleon "ekameleon (6 commits)")

---

Tags

iso8601phpphp8rulesvalidationvalidator

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/oihana-php-validation/health.svg)](https://phpackages.com/packages/oihana-php-validation)
```

###  Alternatives

[chaoswey/taiwan-id-validator

台灣身分證、統一編號驗證

319.9k](/packages/chaoswey-taiwan-id-validator)

PHPackages © 2026

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