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

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

simsoft/validator
=================

A Laravel-inspired validation wrapper for Symfony Validator with custom rules, error handling, and validated input support.

3.0.3(2w ago)04351MITPHPPHP &gt;=8.4CI passing

Since Dec 13Pushed 2w ago2 watchersCompare

[ Source](https://github.com/sim-soft/validator)[ Packagist](https://packagist.org/packages/simsoft/validator)[ Docs](https://github.com/simsoft/validator)[ RSS](/packages/simsoft-validator/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)Dependencies (10)Versions (20)Used By (1)

Simsoft Validator
=================

[](#simsoft-validator)

[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://opensource.org/licenses/MIT)[![PHP](https://camo.githubusercontent.com/a45aab3e57d6c3b0e88082ce085398f9d5523f80794d109fb4757692650c28cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342532422d3737374242342e7376673f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://www.php.net/)[![Docs](https://camo.githubusercontent.com/5b71c5998edb2f63cb60d78c7fa31f7bafe770d91f82a392043e4141899264e1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d6f6e6c696e652d626c75652e737667)](https://sim-soft.github.io/validator/)

A Laravel-inspired validation wrapper for [Symfony Validator](https://symfony.com/doc/current/validation.html). Simple API, full power of Symfony constraints.

**📖 [Full Documentation](https://sim-soft.github.io/validator/)**

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

[](#requirements)

- PHP &gt;= 8.4
- Symfony Validator ^8

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

[](#installation)

```
composer require simsoft/validator
```

Basic Usage
-----------

[](#basic-usage)

```
use Simsoft\Validator;
use Simsoft\Validator\Rule;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;

$validator = Validator::make($_POST, [
    // bail: stops at first failure — only one error reported
    'email' => Rule::bail([
        new NotBlank(message: 'Email is required'),
        new Email(message: 'Invalid email'),
    ]),
    // array: runs all constraints — collects all errors
    'password' => [
        new NotBlank(message: 'Password is required'),
        new Length(
            min: 8,
            max: 20,
            minMessage: 'Minimum {{ limit }} characters are required',
            maxMessage: 'Maximum {{ limit }} characters exceeded',
        ),
    ],
]);

if ($validator->passes()) {
    $data = $validator->validated();
} else {
    echo $validator->errors()->first('email');
}
```

**`Rule::bail()` vs array rules:**

- `Rule::bail([...])` — stops at the first failing constraint (short-circuit)
- `[...]` (plain array) — runs all constraints and collects all violations

Retrieving Validated Data
-------------------------

[](#retrieving-validated-data)

```
$validated = $validator->validated();              // all validated data
$email = $validator->validated('email');           // single attribute value

$data = $validator->safe()->only(['email']);       // subset of validated data
$data = $validator->safe()->except(['remember_me']); // exclude specific keys

foreach ($validator->safe() as $key => $value) {
    // iterate validated attributes
}
```

Handling Errors
---------------

[](#handling-errors)

```
if ($validator->fails()) {
    echo $validator->errors()->first('email');     // first error for attribute
    $errors = $validator->errors()->all();         // all errors as an array
    $count = count($validator->errors());          // number of failed attributes

    if ($validator->errors()->has('email')) {
        // attribute has errors
    }

    foreach ($validator->errors()->get('email') as $message) {
        echo $message;                            // iterate attribute errors
    }

    foreach ($validator->errors() as $attribute => $messages) {
        // iterate all errors
    }
}
```

Custom Validator Class
----------------------

[](#custom-validator-class)

```
namespace App\Validators;

use Simsoft\Validator;
use Simsoft\Validator\Rule;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotBlank;

class LoginValidator extends Validator
{
    protected array $attributes = ['email', 'password', 'remember_me' => false];

    protected function rules(): array
    {
        return [
            'email' => Rule::bail([
                new NotBlank(message: 'Email is required'),
                new Email(message: 'Invalid email'),
            ]),
            'password' => new NotBlank(message: 'Password is required'),
        ];
    }
}
```

```
$validator = LoginValidator::make($_POST);

if ($validator->passes()) {
    $data = $validator->validated();
}
```

Documentation
-------------

[](#documentation)

**📖 [Read the Full Documentation](https://sim-soft.github.io/validator/)**

- [Getting Started](https://sim-soft.github.io/validator/#/getting-started)
- [Custom Rules with Closures](https://sim-soft.github.io/validator/#/custom-rules)
- [Reusable Custom Constraints](https://sim-soft.github.io/validator/#/custom-constraints)
- [Validation Groups](https://sim-soft.github.io/validator/#/validation-groups)
- [Nested &amp; Wildcard Array Validation](https://sim-soft.github.io/validator/#/array-validation)
- [Conditional &amp; Optional Rules](https://sim-soft.github.io/validator/#/conditional-rules)
- [After Hooks &amp; Cross-Field Validation](https://sim-soft.github.io/validator/#/after-hooks)
- [Runtime Rules &amp; Configuration](https://sim-soft.github.io/validator/#/runtime-rules)
- [Comparison with Other Validators](https://sim-soft.github.io/validator/#/comparison)

Available Constraints
---------------------

[](#available-constraints)

All Symfony validation constraints are supported. See [Symfony Validation Constraints](https://symfony.com/doc/current/validation.html#constraints).

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance96

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 76.3% 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 ~98 days

Total

14

Last Release

18d ago

Major Versions

1.0.5 → 2.0.02024-06-10

2.0.3 → 3.0.02026-04-24

PHP version history (5 changes)1.0.0PHP ^8.1|^8.2

1.0.4PHP ^8.1

2.0.0PHP ^8

2.0.1PHP &gt;=8.2

3.0.0PHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c3e6315469b56ed1797318e31e05bcddb12dba268488a2fb0cd2b43971c9ac3?d=identicon)[vzangloo](/maintainers/vzangloo)

---

Top Contributors

[![vzangloo](https://avatars.githubusercontent.com/u/1908200?v=4)](https://github.com/vzangloo "vzangloo (29 commits)")[![sim-soft](https://avatars.githubusercontent.com/u/118705222?v=4)](https://github.com/sim-soft "sim-soft (9 commits)")

---

Tags

phpsymfonylaravelvalidatorvalidationrulesform validationconstraintsinput-validationsimsoft

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/simsoft-validator/health.svg)](https://phpackages.com/packages/simsoft-validator)
```

###  Alternatives

[barbieswimcrew/zip-code-validator

Constraint class for international zipcode validation

772.5M](/packages/barbieswimcrew-zip-code-validator)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[iutrace/laravel-cuit-validator

Argentinian CUIT and CUIL Validator

1013.4k](/packages/iutrace-laravel-cuit-validator)

PHPackages © 2026

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