PHPackages                             kasperh90/symfony-extra-constraints - 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. kasperh90/symfony-extra-constraints

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

kasperh90/symfony-extra-constraints
===================================

A collection of additional validation constraints for the Symfony Validator component

v1.0.0(1w ago)09↑566.7%MITPHPPHP &gt;=8.2

Since Mar 11Pushed 1w agoCompare

[ Source](https://github.com/kasperh90/symfony-extra-constraints)[ Packagist](https://packagist.org/packages/kasperh90/symfony-extra-constraints)[ Docs](https://github.com/kasperh90/symfony-extra-constraints)[ RSS](/packages/kasperh90-symfony-extra-constraints/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Symfony Extra Constraints
=========================

[](#symfony-extra-constraints)

A collection of additional validation constraints for the [Symfony Validator](https://github.com/symfony/validator) component.

[![PHP Version](https://camo.githubusercontent.com/4f0ff8d47b7c73441eb92a1f49af61c2d6521b14113c8fd85fac4416c863e7cc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e322d626c7565)](https://camo.githubusercontent.com/4f0ff8d47b7c73441eb92a1f49af61c2d6521b14113c8fd85fac4416c863e7cc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e322d626c7565)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)

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

[](#installation)

```
composer require kasperh90/symfony-extra-constraints
```

Usage
-----

[](#usage)

Import the constraints:

```
use Kasperh90\SymfonyExtraConstraints\Validator\Constraints as ExtraAssert;
```

### Sum

[](#sum)

Validates the sum of an iterable of numeric values.

#### Options

[](#options)

- `exactly`: The exact expected sum of the collection. When set, the constraint ensures that the sum of all values equals this value.
- `min`: The minimum allowed sum of the collection.
- `max`: The maximum allowed sum of the collection.
- `exactMessage`: The message shown if the sum of the collection does not equal the expected value.
- `minMessage`: The message shown if the sum of the collection is lower than the configured minimum.
- `maxMessage`: The message shown if the sum of the collection exceeds the configured maximum.
- `notNumericMessage`: The message shown when a value in the collection is not numeric.

#### Default options

[](#default-options)

- `groups`: The validation groups this constraint belongs to
- `payload`: Domain-specific data attached to the constraint

#### Example

[](#example)

```
use Kasperh90\SymfonyExtraConstraints\Validator\Constraints as ExtraAssert;

class Allocation
{
    #[ExtraAssert\Sum(exactly: 100)]
    public array $percentages;

    #[ExtraAssert\Sum(min: 10)]
    public array $scores;

    #[ExtraAssert\Sum(max: 500)]
    public array $expenses;
}
```

License
-------

[](#license)

This package is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance98

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

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

10d ago

### Community

Maintainers

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

---

Tags

symfonyvalidatorvalidationconstraintssymfony-validator

### Embed Badge

![Health badge](/badges/kasperh90-symfony-extra-constraints/health.svg)

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

###  Alternatives

[barbieswimcrew/zip-code-validator

Constraint class for international zipcode validation

772.2M](/packages/barbieswimcrew-zip-code-validator)[rollerworks/password-strength-validator

Password-strength validator for Symfony

1455.6M5](/packages/rollerworks-password-strength-validator)[kiczort/polish-validator-bundle

Symfony bundle with validators for Polish identification numbers: PESEL, NIP, REGON, PWZ.

1123.0k](/packages/kiczort-polish-validator-bundle)

PHPackages © 2026

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