PHPackages                             keevitaja/rulez - 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. keevitaja/rulez

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

keevitaja/rulez
===============

User input validation

14234PHP

Since Mar 3Pushed 12y ago1 watchersCompare

[ Source](https://github.com/keevitaja/rulez-laravel)[ Packagist](https://packagist.org/packages/keevitaja/rulez)[ RSS](/packages/keevitaja-rulez/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Rulez - Validation for Laravel
==============================

[](#rulez---validation-for-laravel)

[![Build Status](https://camo.githubusercontent.com/e38c3fe35a592ffd0e500db00a900efda7445573c240f9287b3e782e3ff5105e/68747470733a2f2f7472617669732d63692e6f72672f6b6565766974616a612f72756c657a2d6c61726176656c2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/keevitaja/rulez-laravel)[![ProjectStatus](https://camo.githubusercontent.com/a73fc8052b1241855a0e3766793ed52886419a24a7dfebfc66664a65f301ae47/687474703a2f2f7374696c6c6d61696e7461696e65642e636f6d2f6b6565766974616a612f72756c657a2d6c61726176656c2e706e67)](http://stillmaintained.com/keevitaja/keeper-laravel)

Rulez provides easy way for setting up input validation rules and validation service. You can add all your rules from one place and later use a facade to validate input.

Rulez can set sepparate rule for create and update methods. Handy when there's a unique field.

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

[](#installation)

Require keevitaja/rulez with composer

`composer require keevitaja/rulez:dev-master`

Add service provider and alias to `app/config/app.php`

```
'providers' => array(

    'Keevitaja\Rulez\RulezServiceProvider',

),
```

```
'aliases' => array(

    'Rulez'           => 'Keevitaja\Rulez\RulezFacade'

),
```

Usage
-----

[](#usage)

Validation rules can be set up in various places, like routes.php, but probably best way would be to create `app/rules.php` file and require it in the `app/start/global.php`.

```
require app_path().'/rules.php';
```

### Setting the input validation rules

[](#setting-the-input-validation-rules)

Rules can be set sepparately for creation and update. Base rules will apply for both. In the example below, `users` is the name for the rule set, which can be used later in the controller.

```
Rulez::register('users', function($rulez)
{
    $rulez->addBase([
        'first_name' => 'required|min:2',
        'last_name' => 'required|min:2',
        'password' => 'required|min:6'
    ]);

    $rulez->addCreate([
        'email' => 'required|unique:users|email'
    ]);

    $rulez->addUpdate([
        'email' => 'required|unique:users,email,%s|email'
    ]);
});
```

If you do not need sepparate rules for create and update, then just use base rules.

### Validating the input

[](#validating-the-input)

`Rulez::validateBase($name, $input)`

Validates base rules.

`Rulez::validateCreate($name, $input)`

Merges create and base rules and validates.

`Rulez::validateUpdate($name, $input, $exclude = false)`

Merges update and base rules, sets the row id for case there's a unique column and validates.

`'users'` is the name used with the rule registration in `app/rules.php`.

See the example below:

```
$input = Input::all();

if (Rulez::validateUpdate('users', $input, $id))
{
    // all ok, lets do the update and redirect
}

// something does not validate, send user back with errors and input

return Redirect::back()->withErrors(Rulez::validationErrors())->withInput();
```

If you like this
----------------

[](#if-you-like-this)

please follow me [@keevitaja](https://twitter.com/keevitaja)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/095d59168b7cb0cf90ecb948c3e7de7a58e1528e7a19759a628ea15db65f3b72?d=identicon)[keevitaja](/maintainers/keevitaja)

---

Top Contributors

[![keevitaja](https://avatars.githubusercontent.com/u/158787?v=4)](https://github.com/keevitaja "keevitaja (16 commits)")

### Embed Badge

![Health badge](/badges/keevitaja-rulez/health.svg)

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

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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