2017 © Pedro Peláez
 

library lumberjack-validation

image

rareloop/lumberjack-validation

  • Wednesday, May 2, 2018
  • by rareloop
  • Repository
  • 0 Watchers
  • 1 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 31 % Grown

The README.md

Lumberjack Validation

CI Coveralls, (*1)

This package provides a simple way to validate form input. At it's heart it is a thin wrapper around the Rakit Validation library. For documentation on the types of rules you can use refer to their (Github docs)[https://github.com/rakit/validation., (*2)

Once installed, register the Service Provider in config/app.php:, (*3)

'providers' => [
    ...

    Rareloop\Lumberjack\Validation\ValidationServiceProvider::class,

    ...
],

You can now create Form objects that can be used to validate for your form submissions:, (*4)

Create a Form Object

class ContactForm extends AbstractForm
{
    protected $rules = [
        'name' => 'required',
        'email' => 'required|email'
    ];
}

Use the form to validate input

Your form can be injected into your Lumberjack Controllers and then used this this:, (*5)

use App\Forms\ContactForm;

class IndexController
{
    public function handle(ContactForm $form)
    {
        if ($form->validate($_POST)) {
            // Everything's good - do something with the input
        } else {
            $errors = $form->errors();
            $values = $form->values();
            // Re-show the form with the errors and entered values
        }
    }
}

The Versions