PHPackages                             michaeljennings/validation - 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. michaeljennings/validation

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

michaeljennings/validation
==========================

A laravel 4 validation package

v1.0(11y ago)038PHPPHP &gt;=5.3.0

Since Dec 27Pushed 11y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

Validation [![Latest Stable Version](https://camo.githubusercontent.com/52366262efaf9c026b19e9ef4210bbeb1932ac77d570c3f9050afb19520dd02b/68747470733a2f2f706f7365722e707567782e6f72672f6d69636861656c6a656e6e696e67732f76616c69646174696f6e2f762f737461626c65)](https://packagist.org/packages/michaeljennings/validation) [![Latest Unstable Version](https://camo.githubusercontent.com/a77f728ec7f3526f2807bbccd5c9c04df7058ccf51df61a1f430372a3d6c4c97/68747470733a2f2f706f7365722e707567782e6f72672f6d69636861656c6a656e6e696e67732f76616c69646174696f6e2f762f756e737461626c65)](https://packagist.org/packages/michaeljennings/validation) [![License](https://camo.githubusercontent.com/0d7a02cd0813ee9ca7eb3313bb0d162ce8727fb82ff3b1c29d174a4f14716470/68747470733a2f2f706f7365722e707567782e6f72672f6d69636861656c6a656e6e696e67732f76616c69646174696f6e2f6c6963656e7365)](https://packagist.org/packages/michaeljennings/validation)
================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#validation---)

A laravel 4 validation package aiming to help you clean up your controllers and models, and make validation quicker and simpler.

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

[](#installation)

Include the package in your `composer.json`.

  ```

"michaeljennings/validation": "1.0"

```

Run `composer install` or `composer update` to download the dependencies.

Once the package has been downloaded add the validation service provider to the list of service providers in `app/config/app.php`.

```
  ```

'providers' => array(
'Michaeljennings\Validation\ValidationServiceProvider'

```);

```

Add the `Validation` facade to your aliases array.

```
  ```

'aliases' => array(
'Validation' => 'Michaeljennings\Validation\Facades\Validation',

```);

```

Publish the config files using the `php artisan config:publish michaeljennings/validation`

By default the validators are store in a `app/validators.php` so you may need to create this file. Alternatively if you want to store your validators else where you can update the path in the package config.

Usage
-----

[](#usage)

### Creating a Validator

[](#creating-a-validator)

To create a new validator we use the `add` function. This function takes two arguments, a name for the validator to be called by and a closure with the rules for the validator.

```
  ```

Validation::add('exampleValidator', function($validator)
{
$validator->rule('name')->required();

```});

```

To break this down the `Validation::add('exampleValidator', function($validator) {});` adds a new validator into a collection with the name `'exampleValidator'`.

We then add all of our validation rules on the `$validator` object. To create a new rule we use the `rule` function and then we can chain the laravel validation rules on the rule object.

For example if we wanted to validate an email field to make sure a value was passed and that the value was a valid email address we could use `$validator->rule('email')->required()->email();`.

The validation rules can either be camel cased or snake cased so both `$validator->('foo')->requiredWith('bar');` and `$validator->('foo')->required_with('bar');` are valid.

To see all of the available validation rules [see the laravel docs.](http://laravel.com/docs/4.2/validation#available-validation-rules)

### Validation Error Messages

[](#validation-error-messages)

If you need to set a different validation error message we can use the `message` function. The message function takes two arguments, the validation rule the message is shown for and the error message.

  ```

$validator->rule('foo')->required()->message('required', 'This is a different validation message');

```

### Using a Validator

[](#using-a-validator)

To run a validator we use the `make` function. This function takes two arguments, the name of the validator we want to run and the input to be validated. When we call the make function the validator is bound to the validation class so we can call any of the laravel validation functions on the Validation facade.

```
  ```

Validation::make('exampleValidator', Input::all());

```if (Validation::passes()) {
// Handle success
} else {
return Redirect::back()->withErrors(Validation::errors());
}

```

You can also chain functions when using the `make` function, for example:

  ```

if (Validation::make('exampleValidator', Input::all())->fails()) {
  return Redirect::back()->withErrors(Validation::errors());
}

```

If you need to add a rule to the validator after it has been made you can do so by using the `rule`function to create the new rules and then the `createRules` function to update the validators rules.

```
  ```

Validation::make('exampleValidator', Input::all());

```Validation::rule('foo')->required();
Validation::createRules();

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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 ~0 days

Total

2

Last Release

4151d ago

### Community

Maintainers

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

---

Top Contributors

[![michaeljennings](https://avatars.githubusercontent.com/u/5189701?v=4)](https://github.com/michaeljennings "michaeljennings (19 commits)")

### Embed Badge

![Health badge](/badges/michaeljennings-validation/health.svg)

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

###  Alternatives

[spatie/laravel-honeypot

Preventing spam submitted through forms

1.6k6.0M60](/packages/spatie-laravel-honeypot)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[sunspikes/clamav-validator

Custom Laravel 5 anti-virus validator for file uploads.

3651.8M3](/packages/sunspikes-clamav-validator)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)

PHPackages © 2026

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