PHPackages                             popcorn4dinner/policies - 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. popcorn4dinner/policies

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

popcorn4dinner/policies
=======================

easy to use, non-opinionated library to model complex rules for validations, access control, etc

0.2.0(7y ago)04MITPHPPHP &gt;=7.1

Since Apr 17Pushed 7y ago1 watchersCompare

[ Source](https://github.com/popcorn4dinner/php-policies)[ Packagist](https://packagist.org/packages/popcorn4dinner/policies)[ RSS](/packages/popcorn4dinner-policies/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

PHP Policies
============

[](#php-policies)

A PHP library to easily model complex rules or policies for validations, access control, etc

installation
------------

[](#installation)

```
composer require popcorn4dinner/policies
```

Example: Validating a user
--------------------------

[](#example-validating-a-user)

1. define actions or events as an enum, here CREATE, REGISTER, UPDATE, DELETE and ADMIN\_UPDATE
2. create one policy for each of your business rules
3. create a Validator to use your policies and define exceptions

### creating policies

[](#creating-policies)

#### email address must have the right format

[](#email-address-must-have-the-right-format)

```
