PHPackages                             sunnyflail/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. sunnyflail/constraints

ActiveLibrary

sunnyflail/constraints
======================

A simple validation library

1.0.0(4y ago)0131MITPHP

Since Jul 29Pushed 4y ago1 watchersCompare

[ Source](https://github.com/SunnyFlail/Constraints)[ Packagist](https://packagist.org/packages/sunnyflail/constraints)[ RSS](/packages/sunnyflail-constraints/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (2)Used By (1)

Constraints
===========

[](#constraints)

This library provides basic constraints

1 Primitive value Constraints
=============================

[](#1-primitive-value-constraints)

1.1 EmailConstraint
-------------------

[](#11-emailconstraint)

[A simple constraint for validating email adresses](src/Constraints/EmailConstraint.php)

```
$constraint = new SunnyFlail\Constraints\Constraints\EmailConstraint()
```

This constraint constructor doesn't take any parameters

1.2 EqualsConstraint
--------------------

[](#12-equalsconstraint)

[A simple constraint for validating number equality](src/Constraints/EqualsConstraint.php)

```
$constraint = new SunnyFlail\Constraints\Constraints\EqualsConstraint()
```

This constraint constructor takes in one parameter:
`int|float $equals` - The number to which provided number must be equal to

1.3 GreaterThanConstraint
-------------------------

[](#13-greaterthanconstraint)

[A simple constraint for validating number](src/Constraints/GreaterThanConstraint.php)

```
$constraint = new SunnyFlail\Constraints\Constraints\GreaterThanConstraint()
```

This constraint constructor takes in two parameters:
`int|float $min` - The number which value must be greater than
`bool $orEqual` - Should this also count in equality

1.4 LesserThanConstraint
------------------------

[](#14-lesserthanconstraint)

[A simple constraint for validating number](src/Constraints/LesserThanConstraint.php)

```
$constraint = new SunnyFlail\Constraints\Constraints\LesserThanConstraint()
```

This constraint constructor takes in two parameters:
`int|float $max` - The number which value must be lesser than
`bool $orEqual` - Should this also count in equality

1.5 LengthConstraint
--------------------

[](#15-lengthconstraint)

[A simple constraint for string length](src/Constraints/LengthConstraint.php)

```
$constraint = new SunnyFlail\Constraints\Constraints\LengthConstraint()
```

This constraint constructor takes in two parameters:
`int $minLength` - Minimum length `?int $maxLength` - Maximum length

1.6 PatternConstraint
---------------------

[](#16-patternconstraint)

[A simple constraint for matching string with regex](src/Constraints/PatternConstraint.php)

```
$constraint = new SunnyFlail\Constraints\Constraints\LengthConstraint()
```

This constraint constructor takes in one parameter:
`string ...$regexes` - Regular expressions to match against

1.7 OneOfConstraint
-------------------

[](#17-oneofconstraint)

[Constraint for matching against of one of constraints](src/Constraints/PatternConstraint.php)

```
$constraint = new SunnyFlail\Constraints\Constraints\LengthConstraint()
```

This constraint constructor takes in one parameter:
`IConstraint ...$constraints` - Constraints to match against

2 File Constraints
==================

[](#2-file-constraints)

2.1 BasicMediaTypeConstraint
----------------------------

[](#21-basicmediatypeconstraint)

[Constraint for matching mime types. ***Unsafe***](src/FileConstraints/BasicMediaTypeConstraint.php)

```
$constraint = new SunnyFlail\Constraints\FileConstraints\BasicMediaTypeConstraint()
```

This constraint constructor takes in one parameter:
`array $allowedTypes` - MIME types to match against

2.2 FileSizeConstraint
----------------------

[](#22-filesizeconstraint)

[Constraint for matching file sizes](src/FileConstraints/FileSizeConstraint.php)

```
$constraint = new SunnyFlail\Constraints\FileConstraints\FileSizeConstraint()
```

This constraint constructor takes in two parameters:
`int|null $max` - Maximum allowed file size in bytes
`int|null $min` - Minimum allowed file size in bytes

2.3 NoErrorConstraint
---------------------

[](#23-noerrorconstraint)

[Constraint for checking upload error](src/FileConstraints/NoErrorConstraint.php)

```
$constraint = new SunnyFlail\Constraints\FileConstraints\NoErrorConstraint()
```

This constraint constructor doesn't take any parameters

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

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

1748d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/50b47ac5307f9f924ae62916c792bbfcabe962da1a0eaf68230b2199d4a6283f?d=identicon)[SunnyFlail](/maintainers/SunnyFlail)

---

Top Contributors

[![SunnyFlail](https://avatars.githubusercontent.com/u/82274752?v=4)](https://github.com/SunnyFlail "SunnyFlail (1 commits)")

### Embed Badge

![Health badge](/badges/sunnyflail-constraints/health.svg)

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

###  Alternatives

[league/uri-interfaces

Common tools for parsing and resolving RFC3987/RFC3986 URI

538204.9M23](/packages/league-uri-interfaces)[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[simplesamlphp/saml2

SAML2 PHP library from SimpleSAMLphp

30317.2M40](/packages/simplesamlphp-saml2)[php-heroku-client/php-heroku-client

A PHP client for the Heroku Platform API

24404.8k4](/packages/php-heroku-client-php-heroku-client)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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