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

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

switon/validation
=================

Attribute-driven validation with normalization and locale-aware error messages for Switon Framework

v1.0.0(1mo ago)0365MITPHPPHP &gt;=8.3CI passing

Since Jun 6Pushed 1mo agoCompare

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

READMEChangelogDependencies (4)Versions (2)Used By (5)

Switon Validation Package
=========================

[](#switon-validation-package)

[![CI](https://camo.githubusercontent.com/f085fd0b6917178cef9d573016c08bd31d1f1c6493d39cc5ba48aafa77913bd3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f737769746f6e2d7068702f76616c69646174696f6e2f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4349)](https://github.com/switon-php/validation/actions/workflows/ci.yml) [![PHP 8.3+](https://camo.githubusercontent.com/c03f51341eebaefabbf137e291b20523fc74b4ffd084406d88524d266d95085d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d373737424234)](https://www.php.net/)

Switon's validation layer for constraint attributes, typed input conversion, and localized error messages.

Highlights
----------

[](#highlights)

- **Constraint attributes:** `Required`, `Length`, `Email`, and related attributes validate fields directly.
- **Typed values:** `Type` and `Defaults` can fill and cast values during validation.
- **Validation flow:** one-shot and manual validation are both supported.
- **Localized messages:** template files provide per-locale fallback messages and labels.

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

[](#installation)

```
composer require switon/validation
```

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

[](#quick-start)

```
use Switon\Validating\Attribute\Defaults;
use Switon\Validating\Attribute\Email;
use Switon\Validating\Attribute\Length;
use Switon\Validating\Attribute\Required;
use Switon\Validating\Attribute\Type;
use Switon\Core\Attribute\Autowired;
use Switon\Validating\ValidatorInterface;

final class UserService
{
    #[Autowired] protected ValidatorInterface $validator;

    public function register(array $input): array
    {
        return $this->validator->validateValues($input, [
            'email' => [new Required(), new Email()],
            'name' => [new Required(), new Length(2, 32)],
            'age' => [new Defaults(18), new Type('int')],
        ]);
    }
}
```

Docs:

License
-------

[](#license)

MIT.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance90

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity48

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

Unknown

Total

1

Last Release

49d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dc0f20ad15b0ae9fbf9c6e2cd3008692b0c88a877ec8d3e0119211314bf86fc8?d=identicon)[switon](/maintainers/switon)

---

Top Contributors

[![switon-php](https://avatars.githubusercontent.com/u/247358032?v=4)](https://github.com/switon-php "switon-php (1 commits)")

---

Tags

contraintsswitonvalidationvalidatorvalidatorvalidationconstraintsswiton

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[respect/validation

The most awesome validation engine ever created for PHP

6.0k39.9M418](/packages/respect-validation)[opis/json-schema

Json Schema Validator for PHP

65543.6M320](/packages/opis-json-schema)[vlucas/valitron

Simple, elegant, stand-alone validation library with NO dependencies

1.7k4.6M142](/packages/vlucas-valitron)[intervention/validation

Additional validation rules for the Laravel framework

6827.2M20](/packages/intervention-validation)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.4M50](/packages/proengsoft-laravel-jsvalidation)[wixel/gump

A fast, extensible &amp; stand-alone PHP input validation class that allows you to validate any data.

1.2k1.4M33](/packages/wixel-gump)

PHPackages © 2026

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