PHPackages                             codezero/validator - 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. codezero/validator

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

codezero/validator
==================

Form input validator

1.0.1(11y ago)117MITPHPPHP &gt;=5.4.0

Since Aug 10Pushed 11y ago2 watchersCompare

[ Source](https://github.com/codezero-be/validator)[ Packagist](https://packagist.org/packages/codezero/validator)[ RSS](/packages/codezero-validator/feed)WikiDiscussions master Synced 1w ago

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

Form Input Validator
====================

[](#form-input-validator)

[![Build Status](https://camo.githubusercontent.com/95d6f3f06b64ed37e5641cd707f24c285b65ccdf4a6d59e54aa721070bb07231/68747470733a2f2f7472617669732d63692e6f72672f636f64657a65726f2d62652f76616c696461746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/codezero-be/validator)[![Latest Stable Version](https://camo.githubusercontent.com/7eeb0f97edf6173000efbb336a75f0e8ea5e6e0556d8e63d1013a39190d59ca1/68747470733a2f2f706f7365722e707567782e6f72672f636f64657a65726f2f76616c696461746f722f762f737461626c652e737667)](https://packagist.org/packages/codezero/validator)[![Total Downloads](https://camo.githubusercontent.com/fa984faa4c69fe0f91d95e1036c3721177a94d1dd722cd7f243c4d38e41458f9/68747470733a2f2f706f7365722e707567782e6f72672f636f64657a65726f2f76616c696461746f722f646f776e6c6f6164732e737667)](https://packagist.org/packages/codezero/validator)[![License](https://camo.githubusercontent.com/4308bc29575dc1b4901e7d39b0f0d222682f3feaa1361f3ddb06dea07516f044/68747470733a2f2f706f7365722e707567782e6f72672f636f64657a65726f2f76616c696461746f722f6c6963656e73652e737667)](https://packagist.org/packages/codezero/validator)

This package provides an easy to use interface to handle server side form validation and lets you create your custom form validation classes without much effort.

Although the core of this package is not bound to any framework, I have included a ServiceProvider and ValidationService implementation specifically for [Laravel](http://www.laravel.com/).

I have also included a ValidationTrait and a facade (both for Laravel) so you can use this package in a way you like best (see below for more).

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

[](#installation)

Install this package through Composer:

```
"require": {
	"codezero/validator": "1.*"
}

```

Laravel 4 Implementation
------------------------

[](#laravel-4-implementation)

After installing, update your `app/config/app.php` file to include a reference to this package's service provider in the providers array:

```
'providers' => [
    'CodeZero\Validator\ValidatorServiceProvider'
]

```

This package will automatically register the `Validate` alias, if this is not already taken.

You can handle failed validations by catching the ValidationException. One automated way is to add the following handler to `app/start/global.php`. But you could as easily catch it in a try/catch block.

```
App::error(function(CodeZero\Validator\Exceptions\ValidationException $exception)
{
    return Redirect::back()->withInput()->withErrors($exception->getErrors());
});

```

### Laravel Specific Usage

[](#laravel-specific-usage)

#### 1. Create a FormValidator to validate your form

[](#1-create-a-formvalidator-to-validate-your-form)

```
use CodeZero\Validator\FormValidator;

class UpdateUserForm extends FormValidator {

	/**
     * Validation rules
     *
     * @var array
     */
    protected $rules = [
        'name' => 'required',
        'email' => 'required|email|unique,email,{userId}'
    ];

}

```

Note the `{userId}` placeholder as an example.

#### 2. Handle the input

[](#2-handle-the-input)

Create your form and then handle the input in your controller in one of the following ways.

##### Validate with a facade:

[](#validate-with-a-facade)

```
$input = Input::all();
$vars = ['{userId}' => $someUser->id];

Validate::form('UpdateUserForm', $input, $vars);

```

You can pass the input and any placeholder key/value pairs as the second and third parameter, but if you leave both off, the package will automatically fetch `Input::all()` for you.

To have typesafety or autocomplete in IDE's, you might do this instead:

```
Validate::form(get_class(UpdateUserForm), $input, $vars);

```

Or if you use PHP 5.5 or above, this is even cleaner:

```
Validate::form(UpdateUserForm::class, $input, $vars);

```

##### Validate with a trait:

[](#validate-with-a-trait)

```
use CodeZero\Validator\Support\ValidatorTrait;

class HomeController extends BaseController {

    use ValidatorTrait;

	public function update()
	{
        $input = Input::all();
        $vars = ['{userId}' => $someUser->id];

		$this->validate(UpdateUserForm::class, $input, $vars);

        return Redirect::to('/');
	}

}

```

#### 3. Show any validation errors

[](#3-show-any-validation-errors)

Showing the errors in your form is as easy as doing this for each field:

```
{{ $errors->first('name', ':message'); }}

```

That's it!

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

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

Total

2

Last Release

4287d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2e17b7a892452367dfb0e5c55bf04844a16bb781f356f50019332d4b9a476ec6?d=identicon)[codezero](/maintainers/codezero)

---

Top Contributors

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

---

Tags

laravelvalidationforminput

### Embed Badge

![Health badge](/badges/codezero-validator/health.svg)

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

###  Alternatives

[proengsoft/laravel-jsvalidation

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

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[laravel-lang/attributes

Translation of form element names

273.8M11](/packages/laravel-lang-attributes)[arondeparon/laravel-request-sanitizer

An easy to use request sanitizer that allows you to sanitize your form data before validating it.

112151.6k1](/packages/arondeparon-laravel-request-sanitizer)[lrgt/laravel-form-ajax-validation

Make ajax validation with Laravel Requests for forms with bootstrap

435.6k](/packages/lrgt-laravel-form-ajax-validation)

PHPackages © 2026

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