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

ActiveSymfony-bundle[Validation &amp; Sanitization](/categories/validation)

respect/validation-bundle
=========================

Symfony RespectValidationBundle

17463[2 issues](https://github.com/Respect/ValidationBundle/issues)PHP

Since Jun 10Pushed 11y ago8 watchersCompare

[ Source](https://github.com/Respect/ValidationBundle)[ Packagist](https://packagist.org/packages/respect/validation-bundle)[ RSS](/packages/respect-validation-bundle/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Respect/ValidationBundle
========================

[](#respectvalidationbundle)

Symfony bundle for [Respect/Validation](https://github.com/Respect/Validation).

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

[](#installation)

```
composer require respect/validation-bundle
```

Register the bundle in `config/bundles.php`:

```
return [
    // ...
    Respect\ValidationBundle\RespectValidationBundle::class => ['all' => true],
];
```

Usage
-----

[](#usage)

Inject `Respect\Validation\ValidatorBuilder` into any service via constructor injection:

```
use Respect\Validation\ValidatorBuilder;

final class MyService
{
    public function __construct(private readonly ValidatorBuilder $validator)
    {
    }

    public function process(mixed $value): void
    {
        $this->validator->stringType()->length(1, 100)->check(
            $value,
            new \DomainException('Invalid value.')
        );

        // proceed...
    }
}
```

`ValidatorFactory` is also available for autowiring if you need to build validators programmatically.

Custom rule namespaces
----------------------

[](#custom-rule-namespaces)

Add your own rule namespaces in `config/packages/respect_validation.yaml`:

```
respect_validation:
    rule_namespaces:
        - App\Validation\Rules
```

Rule classes under those namespaces (extending `Respect\Validation\Validators\Core\Simple`) become available via the builder — e.g. a class `App\Validation\Rules\AcmeId` can be used as `$builder->acmeId()->isValid($value)`. User namespaces are checked before the built-in `Respect\Validation\Validators`, so custom rules can shadow defaults.

Container ownership
-------------------

[](#container-ownership)

The bundle replaces `Respect\Validation\ContainerRegistry`'s default container with Symfony's container, so `v::email()`, `ValidatorBuilder::init()`, and every other entry point in Respect/Validation resolves through the same container that serves your Symfony services. This happens at two points:

1. **Compile time** — a compiler pass calls `ContainerRegistry::setContainer()`with the `ContainerBuilder` while the container is being built. Any compiler pass running after this one can call the static API safely.
2. **Runtime** — the bundle overrides `setContainer()` so that the moment the kernel attaches the compiled container to bundles (before any `boot()` runs and before any service is resolved), the registry switches to the runtime container.

The practical guarantee: in any Symfony application code (controllers, console commands, listeners, service constructors), `Respect\Validation\ContainerRegistry`points at Symfony's container. There is no window in normal Symfony usage where the static API would resolve against Respect/Validation's default PHP-DI container.

The only situation this does not cover is code that runs Respect/Validation without a Symfony kernel at all — for example, a standalone script that uses `v::email()` directly. In that scenario there is no bundle to register, and Respect/Validation falls back to its built-in PHP-DI container, which is the expected behaviour outside of Symfony.

License
-------

[](#license)

MIT. See [LICENSE](LICENSE).

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% 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://avatars.githubusercontent.com/u/202642?v=4)[Alexandre Gomes Gaigalas](/maintainers/alganet)[@alganet](https://github.com/alganet)

![](https://avatars.githubusercontent.com/u/154023?v=4)[Henrique Moody](/maintainers/henriquemoody)[@henriquemoody](https://github.com/henriquemoody)

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

---

Top Contributors

[![henriquemoody](https://avatars.githubusercontent.com/u/154023?v=4)](https://github.com/henriquemoody "henriquemoody (9 commits)")[![royopa](https://avatars.githubusercontent.com/u/442991?v=4)](https://github.com/royopa "royopa (2 commits)")[![alganet](https://avatars.githubusercontent.com/u/202642?v=4)](https://github.com/alganet "alganet (1 commits)")[![filhodanuvem](https://avatars.githubusercontent.com/u/94096?v=4)](https://github.com/filhodanuvem "filhodanuvem (1 commits)")[![gabrieljmj](https://avatars.githubusercontent.com/u/2223216?v=4)](https://github.com/gabrieljmj "gabrieljmj (1 commits)")[![nickl-](https://avatars.githubusercontent.com/u/1404606?v=4)](https://github.com/nickl- "nickl- (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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