PHPackages                             fleshgrinder/constraint-violations - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. fleshgrinder/constraint-violations

AbandonedArchivedLibrary[Mail &amp; Notifications](/categories/mail)

fleshgrinder/constraint-violations
==================================

This library provides an implementation of the Notification Pattern with additional functionality to keep code DRY and to be more useful in the context of Domain-Driven Design (DDD) and its value objects.

0.1.0(10y ago)014MITPHPPHP &gt;=7.0.0

Since Mar 23Pushed 10y agoCompare

[ Source](https://github.com/Fleshgrinder/php-constraint-violations)[ Packagist](https://packagist.org/packages/fleshgrinder/constraint-violations)[ Docs](https://github.com/fleshgrinder/php-constraint-violations)[ RSS](/packages/fleshgrinder-constraint-violations/feed)WikiDiscussions master Synced 1mo ago

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

[![Build Status](https://camo.githubusercontent.com/b2cd0516cfa3120b2a3b65f4d334bc2e1bfb6136d353a8f90b37f7dff983a337/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f466c6573686772696e6465722f7068702d636f6e73747261696e742d76696f6c6174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Fleshgrinder/php-constraint-violations)[![Code Climate](https://camo.githubusercontent.com/81312e0f01824f0956fbddf1d337b57b26b26dc9b510e1be99e58204a195eef4/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6769746875622f466c6573686772696e6465722f7068702d636f6e73747261696e742d76696f6c6174696f6e732f6261646765732f6770612e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/Fleshgrinder/php-constraint-violations)[![Test Coverage](https://camo.githubusercontent.com/520ecf17e6ab12940770fb6bfbee3306b0f12e01a65782b64ebec651743217b9/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f636f7665726167652f6769746875622f466c6573686772696e6465722f7068702d636f6e73747261696e742d76696f6c6174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/Fleshgrinder/php-constraint-violations/coverage)[![Packagist](https://camo.githubusercontent.com/344bd8e98a6045f00e15df084dbca386e0f0bac3bc06587f07c825472faaae49/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666c6573686772696e6465722f636f6e73747261696e742d76696f6c6174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fleshgrinder/constraint-violations)[![Packagist License](https://camo.githubusercontent.com/cdb0309b827e7c032e6e44fe6863dc199f00b0f4d2b573693746c7a660773e16/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f666c6573686772696e6465722f636f6e73747261696e742d76696f6c6174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fleshgrinder/constraint-violations)[![VersionEye](https://camo.githubusercontent.com/9bd03eabed596af415dba2c6926aaf61ddd6dcf8e1a1797c6ba97774dd21697c/68747470733a2f2f696d672e736869656c64732e696f2f76657273696f6e6579652f642f757365722f70726f6a656374732f3536663330303263333536333065303033346664396436622e7376673f7374796c653d666c61742d737175617265)](https://www.versioneye.com/user/projects/56f3002c35630e0034fd9d6b)

PHP Constraint Violations
=========================

[](#php-constraint-violations)

This library provides an implementation of the [Notification Pattern](http://martinfowler.com/eaaDev/Notification.html)with additional functionality to keep code DRY and to be more useful in the context of [Domain-Driven Design](http://www.domaindrivendesign.org/) (DDD) and its value objects.

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

[](#installation)

Open a terminal, enter your project directory and execute the following command to add this package to your dependencies:

```
$ composer require fleshgrinder/constraint-violations
```

This command requires you to have Composer installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md) of the Composer documentation.

Usage
-----

[](#usage)

Most basic usage is as illustrated in the following example:

```
$input = 'some data';
$errors = new ViolationCollector();
$warnings = new ViolationCollector();

if (some_validation($input) === false) {
	$errors->addViolation('some message');
}

if (some_other_validation($input) === false) {
	$warnings->addViolation('some other message');
}

// More validations ...

if ($warnings->hasViolations) {
	echo "WARNINGS\n";
	foreach ($warnings->getMessages() as $message) {
		echo "{$message}\n";
	}
}

if ($errors->hasViolations) {
	echo "ERRORS\n";
	foreach ($warnings->getMessages() as $message) {
		echo "{$message}\n";
	}
	exit(1);
}

// Continue ...
```

Please have a look at the [wiki](https://github.com/fleshgrinder/php-constraint-violations/wiki) for more examples.

Weblinks
--------

[](#weblinks)

- Martin Folwer: “*[Replacing Throwing Exceptions with Notification in Validations](http://martinfowler.com/articles/replaceThrowWithNotification.html)*”, in *martinfowler.com*, December 9, 2014.

License
-------

[](#license)

[![MIT License](https://camo.githubusercontent.com/f8370bd5022685ccc4cdebd136a849a7692c5afd674e59ca8805d90f2aa29a72/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f7468756d622f632f63332f4c6963656e73655f69636f6e2d6d69742e7376672f343870782d4c6963656e73655f69636f6e2d6d69742e7376672e706e67)](https://opensource.org/licenses/MIT)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

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

Every ~5 days

Total

3

Last Release

3687d ago

PHP version history (2 changes)0.0.0PHP &gt;=7.0.1

0.0.1PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/6680298143064cd3ac63c0097ef724d46f47221ae0990db445081c4e8a923e05?d=identicon)[Fleshgrinder](/maintainers/Fleshgrinder)

---

Top Contributors

[![Fleshgrinder](https://avatars.githubusercontent.com/u/1059453?v=4)](https://github.com/Fleshgrinder "Fleshgrinder (12 commits)")

---

Tags

validationnotificationnotificationsDomain Driven Designdddconstraintsviolationsviolationmartin fowlernotification pattern

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fleshgrinder-constraint-violations/health.svg)

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

###  Alternatives

[egulias/email-validator

A library for validating emails against several RFCs

11.6k691.3M307](/packages/egulias-email-validator)[mouse0270/bootstrap-growl

This is a simple pluging that turns standard Bootstrap alerts into "Growl-like" notifications.

2.2k119.1k](/packages/mouse0270-bootstrap-growl)[symfony/notifier

Sends notifications via one or more channels (email, SMS, ...)

80640.3M290](/packages/symfony-notifier)[liran-co/laravel-notification-subscriptions

Notification subscription management.

128239.2k1](/packages/liran-co-laravel-notification-subscriptions)[bentools/webpush-bundle

Send push notifications through Web Push Protocol to your Symfony users.

71274.3k](/packages/bentools-webpush-bundle)[naif/nova-push-notification

A Laravel Nova tool to send push notifications via OneSignal

166.4k](/packages/naif-nova-push-notification)

PHPackages © 2026

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