PHPackages                             muffe/enum-constraint - 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. muffe/enum-constraint

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

muffe/enum-constraint
=====================

A Symfony Validator constraint that validates if given strings are valid cases in a given PHP 8 Enum

v0.2.1(1y ago)111.3k↑300%1MITPHPPHP &gt;=8.1

Since Aug 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/muffe/enum-constraint)[ Packagist](https://packagist.org/packages/muffe/enum-constraint)[ RSS](/packages/muffe-enum-constraint/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

enum-constraint
===============

[](#enum-constraint)

A Symfony Validator constraint that validates if given strings are valid cases in a given PHP 8 Enum

```
enum ContactCategory: string
{
    case Child           = 'Child';
    case Grandchild      = 'Grandchild';
}

use Muffe\EnumConstraint\Constraints\Enum;

#[
    Enum(
        enumType: ContactCategory::class,
    )
]
public ?string $category = null;

```

Validates that $category contains a string that is equal to the backed value of one of the given enum cases, or the name of the case if no backed values are given.

```
use Muffe\EnumConstraint\Constraints\Enum;

#[
    Enum(
        enumType: ContactCategory::class,
        multiple: true
    )
]
public ?array $categories = null;

```

Also supports validating multiple given values

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance46

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

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

Every ~320 days

Total

4

Last Release

421d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/366059?v=4)[Marc Wustrack](/maintainers/muffe)[@muffe](https://github.com/muffe)

---

Top Contributors

[![muffe](https://avatars.githubusercontent.com/u/366059?v=4)](https://github.com/muffe "muffe (6 commits)")[![xabbuh](https://avatars.githubusercontent.com/u/1957048?v=4)](https://github.com/xabbuh "xabbuh (1 commits)")

---

Tags

validatorenumconstraint

### Embed Badge

![Health badge](/badges/muffe-enum-constraint/health.svg)

```
[![Health](https://phpackages.com/badges/muffe-enum-constraint/health.svg)](https://phpackages.com/packages/muffe-enum-constraint)
```

###  Alternatives

[barbieswimcrew/zip-code-validator

Constraint class for international zipcode validation

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

Password-strength validator for Symfony

1455.7M6](/packages/rollerworks-password-strength-validator)[form-manager/form-manager

PHP-HTML form manager

16041.0k7](/packages/form-manager-form-manager)[sllh/iso-codes-validator

Symfony validator wrapper of ronanguilloux/isocodes

37299.8k2](/packages/sllh-iso-codes-validator)[kiczort/polish-validator-bundle

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

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

PHPackages © 2026

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