PHPackages                             spajz/modval - 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. [Database &amp; ORM](/categories/database)
4. /
5. spajz/modval

ActiveLibrary[Database &amp; ORM](/categories/database)

spajz/modval
============

Simple model validation for Laravel 4.

1(12y ago)112MITPHPPHP &gt;=5.3.0

Since Mar 25Pushed 10y ago1 watchersCompare

[ Source](https://github.com/spajz/modval)[ Packagist](https://packagist.org/packages/spajz/modval)[ RSS](/packages/spajz-modval/feed)WikiDiscussions master Synced 3d ago

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

Simple model validation for Laravel 4
=====================================

[](#simple-model-validation-for-laravel-4)

---

- Auto validate model on save.
- Use simple or separate rules for model events (create, update and save).
- Based on Jeffrey Way project Laravel Model Validation.

---

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

[](#installation)

Just place require new package for your Laravel installation via composer.json

```
"spajz/modval": "dev-master"

```

Then composer update.

You can add following lines to `app/config/app.php` if you want to use alias:

```
'Modval' => 'Spajz\Modval\Modval'
```

Usage
-----

[](#usage)

Your models need to extend `Modval` or `Spajz\Modval\Modval`.

```
class Foo extends Modval {

}
```

How to add rules in the model (same for all events).

```
class Foo extends Modval {
    protected static $rules = array(
        'title' => 'required',
        'slug' => 'required|min:5',
    );
}
```

Add rules separately for each event (create, update or save). Save event is executed in both cases (create and update).

```
class Foo extends Modval {
    protected static $rules = array(
        'create' => array(
            'slug' => 'required|min:5',
        ),
        'update' => array(
            'url' => 'required',
        ),
        'save' => array(
            'title' => 'required',
        ),
    );
}
```

And here's an example from controller.

```
public function store()
{
    $foo = new Foo(Input::all());

    if ($foo->save()) return Redirect::route('foo.index');

    return Redirect::back()->withInput()->withErrors($foo->getErrors());
}
```

Thanks
------

[](#thanks)

Thanks to Jeffrey Way and his project Laravel Model Validation:

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

Maturity58

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

Unknown

Total

1

Last Release

4433d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/978b6a48807770314fa13da8570235ce8fbd58c5aeb82d5fa7d2b86b5e2bee12?d=identicon)[spajz](/maintainers/spajz)

---

Top Contributors

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

---

Tags

laravelvalidationmodeleloquent

### Embed Badge

![Health badge](/badges/spajz-modval/health.svg)

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

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[wendelladriel/laravel-lift

Take your Eloquent Models to the next level

70046.8k](/packages/wendelladriel-laravel-lift)[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591444.8k2](/packages/spiritix-lada-cache)

PHPackages © 2026

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