PHPackages                             dealnews/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. dealnews/constraints

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dealnews/constraints
====================

Type constraint checking library

v3.0.0(8mo ago)112.1k↓23.1%12BSD-3-ClausePHPPHP ^8.2CI passing

Since Mar 10Pushed 8mo ago7 watchersCompare

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

READMEChangelog (6)Dependencies (3)Versions (9)Used By (2)

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

[](#constraints)

A library for testing primitive and abstract data types in PHP with type juggling.

Supported Primitive Types
-------------------------

[](#supported-primitive-types)

- Integer
- String
- Array
- Double (aka float)
- Boolean
- Any defined PHP class

Supported Abstract Types
------------------------

[](#supported-abstract-types)

- Bytes
- US Currency
- Date
- DateTime
- Length
- Range
- Time
- URL
- URL Path
- Year

Extendable
----------

[](#extendable)

The base `Constraint` class can be extended to add new abstract types.

Example
-------

[](#example)

```
// A very simple example
$constraint = \DealNews\Constraints\Constraint::init();
$value = "1";
try {
    $value = $constraint->check($value, ["type" => "integer"]);
    // $value will now be integer 1
} catch (\DealNews\Constraints\ConstraintException $e) {
    echo $e->getMessage();
}
```

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance60

Regular maintenance activity

Popularity28

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 89.5% 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 ~475 days

Recently: every ~515 days

Total

6

Last Release

251d ago

Major Versions

v1.0.0 → 2.0.02020-01-17

v2.2.1 → v3.0.02025-09-09

PHP version history (3 changes)v1.0.0PHP &gt;=7.1.0

v2.2.0PHP ^8.0

v3.0.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/49531?v=4)[Brian Moon](/maintainers/brianlmoon)[@brianlmoon](https://github.com/brianlmoon)

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

---

Top Contributors

[![brianlmoon](https://avatars.githubusercontent.com/u/49531?v=4)](https://github.com/brianlmoon "brianlmoon (17 commits)")[![jearle-dealnews](https://avatars.githubusercontent.com/u/8784094?v=4)](https://github.com/jearle-dealnews "jearle-dealnews (2 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[pragmarx/support

PragmaRX components support package

591.5M27](/packages/pragmarx-support)[bcremer/line-reader

Read large files line by line in a memory efficient (constant) way.

301.6M4](/packages/bcremer-line-reader)[beelab/recaptcha2-bundle

Provide Google Recaptcha2 form type

55455.1k1](/packages/beelab-recaptcha2-bundle)[lkrms/pretty-php

The opinionated PHP code formatter

14659.1k1](/packages/lkrms-pretty-php)[kreyu/data-table-bundle

Streamlines creation process of the data tables

11299.6k](/packages/kreyu-data-table-bundle)[adhocore/cron-expr

Ultra lightweight Cron Expression parser for PHP

53436.1k3](/packages/adhocore-cron-expr)

PHPackages © 2026

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