rareloop / lumberjack-validation
Installs: 45 308
Dependents: 2
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 1
Open Issues: 1
Requires
- rakit/validation: ^0.13.1
- rareloop/lumberjack-core: ^5.0.0||^6.0.0
Requires (Dev)
- brain/monkey: ^2.0.2
- codedungeon/phpunit-result-printer: ^0.4.4
- mockery/mockery: ^1.0.0
- phpunit/phpunit: ^6.0
- satooshi/php-coveralls: ^1.0
- squizlabs/php_codesniffer: ^3.2
This package is auto-updated.
Last update: 2024-11-05 17:35:38 UTC
README
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.
Once installed, register the Service Provider in config/app.php
:
'providers' => [ ... Rareloop\Lumberjack\Validation\ValidationServiceProvider::class, ... ],
You can now create Form objects that can be used to validate for your form submissions:
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:
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 } } }