PHPackages                             ez-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. [Framework](/categories/framework)
4. /
5. ez-php/validation

ActiveLibrary[Framework](/categories/framework)

ez-php/validation
=================

Validation module for the ez-php framework — rule-based validator with database-backed unique/exists rules and optional i18n support

1.11.1(1mo ago)03.3k↓90%1MITPHPPHP ^8.5CI passing

Since Mar 15Pushed 1mo agoCompare

[ Source](https://github.com/ez-php/validation)[ Packagist](https://packagist.org/packages/ez-php/validation)[ Docs](https://github.com/ez-php/validation)[ RSS](/packages/ez-php-validation/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (18)Versions (44)Used By (1)

ez-php/validation
=================

[](#ez-phpvalidation)

Validation module for the [ez-php framework](https://github.com/ez-php/framework) — rule-based validator with database-backed `unique`/`exists` rules and optional i18n support.

[![CI](https://github.com/ez-php/validation/actions/workflows/ci.yml/badge.svg)](https://github.com/ez-php/validation/actions/workflows/ci.yml)

Requirements
------------

[](#requirements)

- PHP 8.5+
- ez-php/framework 0.\*

Installation
------------

[](#installation)

```
composer require ez-php/validation
```

Optionally install [ez-php/i18n](https://github.com/ez-php/i18n) for localised error messages:

```
composer require ez-php/i18n
```

Usage
-----

[](#usage)

```
use EzPhp\Validation\Validator;

$validator = Validator::make(
    data: ['email' => 'alice@example.com', 'age' => 17],
    rules: [
        'email' => 'required|email',
        'age'   => 'required|integer|min:18',
    ],
);

if ($validator->fails()) {
    $errors = $validator->errors();
    // ['age' => ['The age must be at least 18.']]
}

// Or throw on failure:
$validator->validate(); // throws ValidationException
```

Supported rules
---------------

[](#supported-rules)

RuleDescription`required`Field must be present and non-empty`string`Must be a string`integer`Must be an integer`email`Must be a valid email address`min:n`Minimum value (numeric) or minimum length (string)`max:n`Maximum value (numeric) or maximum length (string)`regex:/pattern/`Must match the given regex`unique:table,column`Value must not exist in the given DB column`exists:table,column`Value must exist in the given DB column`confirmed`Value must match `{field}_confirmation` in the input`same:other`Value must equal the value of `other` field`different:other`Value must differ from the value of `other` field`date`Must be a valid date parseable by `strtotime()``date_format:Y-m-d`Must exactly match the given PHP date format`before:date`Must be a date strictly before the reference`after:date`Must be a date strictly after the reference`file`Must be a valid `$_FILES` upload (`UPLOAD_ERR_OK`)`image`Upload MIME type must be `image/*``mimes:jpg,png`Upload file extension must be in the list`max_size:n`Upload size must not exceed `n` kilobytes`dimensions:min_width=N,...`Image dimensions must satisfy the constraints`sometimes`Skip all rules for this field when its key is absent from the dataRules skip silently for absent/empty values (except `required` and `sometimes`). Combine `required` with type rules to enforce both presence and type.

FormRequest
-----------

[](#formrequest)

For controller-level validation with optional authorization, extend `FormRequest`:

```
use EzPhp\Validation\FormRequest;

class StoreUserRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true; // check e.g. Auth::user()->isAdmin()
    }

    public function rules(): array
    {
        return [
            'name'  => 'required|string|max:255',
            'email' => 'required|email',
        ];
    }
}
```

Inject it into a controller action — it validates automatically on instantiation:

```
public function store(StoreUserRequest $request): Response
{
    // reaches here only if validation and authorization passed
    $data = $request->validated();
}
```

`FormRequest` throws `ValidationException` on rule failures and `AuthorizationException` when `authorize()` returns `false`.

With i18n
---------

[](#with-i18n)

Pass a `Translator` instance to receive messages in the configured locale:

```
$translator = $app->make(\EzPhp\I18n\Translator::class);

$validator = Validator::make($data, $rules, translator: $translator);
```

License
-------

[](#license)

MIT — [Andreas Uretschnig](mailto:andreas.uretschnig@gmail.com)

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance91

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 91.1% 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 ~1 days

Total

43

Last Release

44d ago

Major Versions

0.9.3 → 1.0.02026-03-24

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/122030400?v=4)[AU9500](/maintainers/AU9500)[@AU9500](https://github.com/AU9500)

---

Top Contributors

[![AU9500](https://avatars.githubusercontent.com/u/122030400?v=4)](https://github.com/AU9500 "AU9500 (133 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (13 commits)")

---

Tags

phpframeworkvalidatorvalidationez-php

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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