finds.dev← search

// the find

JeffreyWay/Laravel-Model-Validation

★ 276 · PHP · updated Sep 2016

This Laravel package auto-validates a model on save.

A Laravel 4 package that hooks into Eloquent's save event to run validation rules automatically, so you don't repeat the Validator::make dance in every controller. Targets Laravel 4.0 specifically — this is ancient by PHP standards.

The core idea is sound: validation belongs on the model, not scattered across controllers. Hooking into the save event is the right place for it. Custom error messages via a static $messages array is a clean touch. The API is minimal enough that you can understand the whole thing in five minutes.

Last touched in 2016 and targets Laravel 4.0 — Laravel is at 11.x now. This isn't usable in any modern project without a full rewrite. Laravel 5+ shipped FormRequest validation and later added built-in model observers, so the gap this filled no longer exists. The test suite is essentially empty (tests/.gitkeep). Returning false on failed save rather than throwing an exception is a silent failure pattern that causes bugs in real codebases.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →