PHPackages                             einlinuus/php-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. einlinuus/php-validator

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

einlinuus/php-validator
=======================

Minimal library to validate and transform user input

1.0.0(2y ago)06[1 PRs](https://github.com/EinLinuus/php-validator/pulls)GPL-3.0PHP

Since Nov 24Pushed 2y ago1 watchersCompare

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

READMEChangelog (2)DependenciesVersions (4)Used By (0)

PHP Validator
=============

[](#php-validator)

Capabilities
------------

[](#capabilities)

- Check for datatype
- Check for length / amount
- Check for regex
- Check for min / max entries in array
- Check for unique entries in array
- Clean strings (remove double spaces, trim, etc.)
- Check for valid email format
- Check for valid URL format
- Check for specific array shape
- Custom validation functions
- Custom transformation functions

Use cases
---------

[](#use-cases)

- Validate user input
- Validate API input
- Transform input (e.g. convert IDs to objects)

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

[](#installation)

This package can be installed via composer:

```
composer require einlinuus/php-validator

```

> **New to composer?**
>
> Composer is a dependency manager for PHP. Composer can install this package from the [packagist.org registry](https://packagist.org/packages/einlinuus/php-validator). Once installed, you'll find a `vendor` directory in your project.
>
> You can import all required files by importing the `autoload.php` file created by composer: `require_once __DIR__ . "/vendor/autoload.php";` With the autoload-file included in your project, you now have access to all classes and functions provided by this package.

Usage
-----

[](#usage)

Simply create a new instance of the Validator class and pass the input data to the constructor.

Next, chain the validation methods inside a try-catch block. If any of the validation methods fail, a ValidatorException will be thrown.

After the validation methods, you can get the output data by calling the get() method. The output data is your input data transformed by the transformation methods. If no transformation methods are used, the output data will be the same as the input data.

```
$input = "hello world";

$v = new Validator($input);
try {
    $v->isString("Input must be a string")
        ->isLowercase("Input must be lowercase")
        ->min(3, "Input must be at least 3 characters long")
        ->max(12, "Input must be at most 10 characters long");
} catch (ValidatorException $e) {
    die("Invalid: " . $e->getMessage());
}

$validated = $v->get();
var_dump($validated); // string(11) "hello world"
```

You can find more examples in the `examples` folder.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

Total

2

Last Release

813d ago

Major Versions

0.1.0 → 1.0.02024-02-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/324b2eb65af0319a95c986932aba7b960db8937519523d1ce63ddfad583d3eb4?d=identicon)[EinLinuus](/maintainers/EinLinuus)

---

Top Contributors

[![EinLinuus](https://avatars.githubusercontent.com/u/73361682?v=4)](https://github.com/EinLinuus "EinLinuus (7 commits)")

---

Tags

composer-packagephpphp-libraryvalidationvalidator

### Embed Badge

![Health badge](/badges/einlinuus-php-validator/health.svg)

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