Skip to content
Easy form validation for Laravel 4 applications.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Laravel Form Validator - Deprecated

No Maintenance Intended

Inspired by Laracasts' Form Validator this package provides an easy method for validating form data, including checks for unique values.

This package is no longer being maintained.


This package should be installed via composer:

$ composer require srlabs/validator


To use the form validator, first create a form class that extends SRLabs\Validator\Validation\FormValidator. This class will specify the rules and custom messages you want to use when validating this form. For example:

<?php namespace Epiphyte\Forms;

use SRLabs\Validator\Validation\FormValidator;

class UpdateProductionForm extends FormValidator {

    protected $rules = array(
        'name' => 'required|alpha|unique:productions',
        'author' => 'required'

    protected $messages = array(
        'name.unique' => 'There is already a production with that name.'

Next, inject your custom form class into the controller handling your form submission.


use Epiphyte\Forms\CreateProductionForm;
use Epiphyte\Forms\UpdateProductionForm;

class ProductionController extends \BaseController {

    protected $createProductionForm;
    protected $updateProductionForm;

     * @param CreateProductionForm $createProductionForm
    public function __construct(
        CreateProductionForm $createProductionForm,
        UpdateProductionForm $updateProductionForm)
        $this->createProductionForm = $createProductionForm;
        $this->updateProductionForm = $updateProductionForm;

    // ...

To validate form data, do this in your controller method:

public function store()
    // Gather the Data
    $data = Input::only('name', 'author');

    // Validate the Form

    // Create the Production

    Session::flash('success', 'Production Added');
    return Redirect::action('ProductionController@index');

Note that if the validation fails, an exception will be thrown (and subsequently caught) forcing a redirect back to the form, sending along the error messages and old input as well.

To validate a field containing a unique rule, pass the corresponding object to the form class:

public function update($id)
    $production = Epiphyte\Production::find($id);
    $data = Input::only('name', 'author');

    $this->updateProductionForm->validate($data, $production);

    $production->name = $data['name'];
    $production->author = $data['author'];

    Session::flash('success', 'Production Updated');
    return Redirect::action('ProductionController@index');


  • The tests need to be flushed out and greatly improved.
  • Eventually I will add some config options.
You can’t perform that action at this time.