PHPackages                             fesor/symfony-validator-extra - 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. fesor/symfony-validator-extra

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

fesor/symfony-validator-extra
=============================

Symfony Validator Extras for more simple handling of complex cases

v0.1.0(9y ago)815[2 issues](https://github.com/fesor/SymfonyValidatorExtras/issues)MITPHP

Since Oct 18Pushed 9y ago1 watchersCompare

[ Source](https://github.com/fesor/SymfonyValidatorExtras)[ Packagist](https://packagist.org/packages/fesor/symfony-validator-extra)[ RSS](/packages/fesor-symfony-validator-extra/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Symfony Validator Extras
========================

[](#symfony-validator-extras)

In order to simplify request validation and reduce amount of boilerplate, this package provides you set of additional constraints.

Json and FixedJson constraints
------------------------------

[](#json-and-fixedjson-constraints)

If you are dealing with json requests, you probably hate `Collection` validator. As a replacement this library provides you two additional constraints: `JsonValidator` and `FixedJsonValidator`.

The difference between `JsonValidator` and `FixedJsonValidator`, which is both extends from `CollectionValidator`, is that they use different value for option `allowExtraFields`. `FixedJson` doesn't allow extra fields, but `Json` - just ignores that.

### Shortcuts

[](#shortcuts)

This validator provides you some shortcuts for common validators:

```
$rules = new FixedJson([
    'foo' => 'string',
    'bar' => 'email',
    'buz' => 'datetime',
]);
```

this is equivalent of

```
$rules = new Collection([
    'foo' => [new NotNull(), new Type('string')],
    'bar' => [new NotNull(), new Email()],
    'buz' => [new NotNull(), new DateTime()]
]);
```

List of available shortcuts:

ShortCutConstraint Used`date    ``new Date()``datetime``new DateTime()``time    ``new Time()``email   ``new Email()``url     ``new Url()``file    ``new File()``image   ``new Image()``null    ``new IsNull()``*any strhing*``new Type('*any strhing*')`### Null Safety

[](#null-safety)

By default all constraint (except `null`) shortcuts expands with `NotNull` constraint. If `null` is acceptable value for you, you can just add question mark at the beginning of shortcut. So this rules will be equivalent:

```
$rules = new Json([
    'foo' => '?string',
    'bar' => 'string'
]);

$equivalent = new Collection([
    'allowExtraFields' => true,
    'fields' => [
        'foo' => [new Type('string')],
        'bar' => [new NotNull(), new Type('string')]
    ]
]);

```

The syntax is taken from PHP 7.1

### Optional fields

[](#optional-fields)

If your json request has optional keys, then you probably will write something like this:

```
$rules = new Collection([
    'foo' => new Optional([new NotNull(), new Type('string')])
]);
```

With `JsonValidator` the same rule can be written as:

```
$rules = new Json([
    'foo?' => 'string'
]);
```

Please note that question mark (`?`) will be skipped if you manually provide info about is this field is required or not. So using this rule:

```
$fules = new Json([
    'foo?' = new Required([new NotNull()]),
    'bar??' => 'string',
])
```

validator will expect `foo?` containing not null value. And property `bar?` considered as optional since it has question mark in it's end (`?`).

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% 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

3490d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/736e9d33560d4c01cd2b9dfb70bbcbd8219d4b61967f98ffa09d35101ceeaac8?d=identicon)[fesor](/maintainers/fesor)

---

Top Contributors

[![fesor](https://avatars.githubusercontent.com/u/172247?v=4)](https://github.com/fesor "fesor (6 commits)")[![phudinsky](https://avatars.githubusercontent.com/u/5508808?v=4)](https://github.com/phudinsky "phudinsky (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fesor-symfony-validator-extra/health.svg)

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

###  Alternatives

[sllh/iso-codes-validator

Symfony validator wrapper of ronanguilloux/isocodes

37299.8k2](/packages/sllh-iso-codes-validator)[digitalrevolution/symfony-validation-shorthand

Validation shorthand for symfony

12108.5k2](/packages/digitalrevolution-symfony-validation-shorthand)[digitalrevolution/symfony-request-validation

Automatic request validation for symfony

1296.0k](/packages/digitalrevolution-symfony-request-validation)

PHPackages © 2026

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