PHPackages                             armin-dev/validx - 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. armin-dev/validx

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

armin-dev/validx
================

A modern PHP validation library.

00PHP

Since Aug 26Pushed 8mo agoCompare

[ Source](https://github.com/PouyaniArmin/validX)[ Packagist](https://packagist.org/packages/armin-dev/validx)[ RSS](/packages/armin-dev-validx/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Validx
======

[](#validx)

A lightweight and extensible PHP validation library.
Validx provides a simple and readable way to validate data in PHP projects.

Features (v1)
-------------

[](#features-v1)

- Basic validation rules: `required`, `email`, `min`, `max`, `between`, `numeric`, `integer`, `phone`, `url`, `secure`, `unique`, `in`, `alphanumeric`, `date`, `fileType`, `maxfileSize`.
- Supports arrays and nested fields.
- Optional PDO database injection for rules like `unique`.
- Integration-ready for forms, APIs, and any PHP project.

Quick Start
-----------

[](#quick-start)

```
use Validx\Validation;

$validation = new Validation();

$data = [
    'username' => 'exampleuser',
    'email' => 'example@example.com',
];

$rules = [
    'username' => 'required | between:2,15',
    'email' => 'required | email',
];

$errors = $validation->validate($data, $rules);

if (!empty($errors)) {
    print_r($errors);
} else {
    echo "All fields are valid!";
}

## Example Error Output

```php
[
    'username' => ['The username must have between 2 and 15 characters'],
    'email' => ['The email already exists'],
]
```

Available Rules (v1)
--------------------

[](#available-rules-v1)

- `required`
- `email`
- `min`
- `max`
- `between`
- `numeric`
- `integer`
- `phone`
- `url`
- `secure`
- `unique`
- `in`
- `alphanumeric`
- `date`
- `fileType`
- `maxfileSize`

Writing Validation Rules
------------------------

[](#writing-validation-rules)

> Note: All keys defined in your validation rules must exist in the input data array.

Validation rules are defined as strings using pipe `|` separators. You can combine multiple rules per field.

### Examples:

[](#examples)

```
$rules = [
    'username' => 'required | between:3,20',
    'email' => 'required | email | unique:email',
    'password' => 'required | min:6 | max:12 | secure',
    'age' => 'integer | min:18',
];
```

required — The field must not be empty.

email — Must be a valid email address.

unique:email — Must be unique in the database (requires PDO).

min:value / max:value — Minimum or maximum length/value.

between:min,max — Value must be within the given range.

integer — Must be an integer.

secure — Must meet password security criteria

Error Messages
--------------

[](#error-messages)

Validx returns error messages from an internal enum class.
Currently, messages are **not customizable**, but each rule has a predefined message.

### Available Messages Per Rule

[](#available-messages-per-rule)

RuleDefault MessageREQUIREDPlease Enter The %sEMAILThe %s is not a valid email addressMINThe %s must have at least %s charactersMAXThe %s must have at most %s charactersBETWEENThe %s must have between %d and %d charactersSAMEThe %s must match with %sALPHANUMERICThe %s should have only letters and numbersSECUREThe %s must have between 8 and 64 characters and contain at least one number, one upper case letter, one lower case letter and one special characterUNIQUEThe %s already existsNUMERICThe %s must contain only numbersINTEGERThe %s must be an integerURLThe %s is not a valid URLDATEThe %s is not a valid datePHONEThe %s is not a valid phone numberINThe %s must be one of the allowed valuesFILETYPEThe %s must be a valid file type: %sMAXFILESIZEThe %s must not be larger than %s**Note:** `%s` and `%d` are placeholders that will be replaced with field names, min/max values, or file size as appropriate.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance42

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

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/9a466339f302157a8be2df7595714453af381012cc190f124f65feb3c31a28ee?d=identicon)[PouyaniArmin](/maintainers/PouyaniArmin)

---

Top Contributors

[![PouyaniArmin](https://avatars.githubusercontent.com/u/98267004?v=4)](https://github.com/PouyaniArmin "PouyaniArmin (53 commits)")

### Embed Badge

![Health badge](/badges/armin-dev-validx/health.svg)

```
[![Health](https://phpackages.com/badges/armin-dev-validx/health.svg)](https://phpackages.com/packages/armin-dev-validx)
```

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