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

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

revati/laravel-validation
=========================

Laravel validation extension for throwing ValidationException on error

05PHP

Since Feb 2Pushed 12y ago1 watchersCompare

[ Source](https://github.com/revati/laravel-validation)[ Packagist](https://packagist.org/packages/revati/laravel-validation)[ RSS](/packages/revati-laravel-validation/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Exceptional Validation
======================

[](#exceptional-validation)

Validation support in two ways.

- ValidationException throwing and configurable responses
- BaseValidator abstract class with handy functionality

Possibilities
-------------

[](#possibilities)

- No need to worry about what happens if validation fails (ValidationException).
- Can dynamicly assign modifiers to validation rules:

```
// In ResourceValidator that extends Revati\Validation\BaseValidator
$rules = [
    'title' => 'required'
    'endDate'  => 'after:[afterDate]'
];

$resourceValidator->addModifier('date', 'afterDate', Input::get('startDate'));

// So [afterDate] will be replaced with 3th parameter
```

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

[](#installation)

Begin by installing this package through Composer. Edit your project's `composer.json` file to require `revati/validation`.

```
"require": {
    "laravel/framework": "4.1.*",
    "revati/validation": "dev-master"
}

```

Next, update Composer from the Terminal:

```
composer update

```

Once this operation completes, the final step is to add the service provider. Open `app/config/app.php`, and add a new item to the providers array.

```
// 'Illuminate\Validation\ValidationServiceProvider',
'Revati\Validation\ValidationServiceProvider'

```

That's it! You're all set to go.

BaseValidator
-------------

[](#basevalidator)

- Create seperate Validator file for each Resource (should extend `Revati\Validation\BaseValidator`)
- Set all rules that should be applied to Resource

### Get specific rules

[](#get-specific-rules)

- `getRules` method accepts one parameter (array) with list of all rules that should extracted from global $rules.

```
// Will get only title rules
$validator->getRules(array('title'));

// Will get title rules and overwrite description rules
$validator->getRules(array('title', 'description' => 'min:200'));
```

### Dynamic rules modifiers

[](#dynamic-rules-modifiers)

In url specify modifier hook like so: `[modifier]`.

```
// Change hook value
// Modifier should bee passed without square brackets
$validator->addModifier('field', 'min', 20);

// As field name can be passed `*` to search in all field rules.
$validator->addModifier('*', 'max', 100);

// Modifiers can be be grouped
$validator->addModifier('field', 'min|max', 10);
```

ValidationException
-------------------

[](#validationexception)

Caution: By default exception throwing is enabled. So if you dont need it it can be disaled via packages config.

```
php artisan config:publish revati/validation

```

Whatever where you want to validate something

```
// ...

// Validate $input against $rules like usual.
// No need to catch response because if errors will occur, exception
// will be thrown and necessary response returned.
Validator::make($input, $rules);

// If got to this point validation passed
$user = User::create($input);

// For validation only (without throwing exception)
$validator = Validator::sotfMake($input, $rules);

// To disable or enable exception throwing at runtime use fallowing methods:
Validation::disable();
Validation::enable();

// To change response at runtime use fallowing method
Validation::setResponse($responseClosure, $ajaxResponseClosure);

// Change only one response
Validation::setResponse($responseClosure);
Validation::setResponse(null, $ajaxResponseClosure);

// ...
```

If error occur, fallowing responses will be returned:

```
// For "regular" request
return \Redirect::back()
    ->withInput()
    ->withErrors($e->getErrors());

// For ajax request
return \Response::json(array(
    'success' => false,
    'errors' => $e->getErrors()->toJson()
), 400);

// $e stands for ValidationException witch (for now) only has one method
// to return errors -> getErrors.
```

Customize
---------

[](#customize)

Those responses are defined as closures in package config file, so just by publishing package config you can modify what your app should be doing in witch case.

```
php artisan config:publish revati/validation

```

TODO
----

[](#todo)

It is probably out of scope for this package, but planing to add simple js file for automating form submit + error showing on error response.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

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/84364eaaae21f1e2ace7a6be008c887557d173c7776267e72e9c0c34db58cb12?d=identicon)[revati](/maintainers/revati)

---

Top Contributors

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

### Embed Badge

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

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

###  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)
