https://github.com/rareloop/lumberjack-validation
https://github.com/rareloop/lumberjack-validation
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rareloop/lumberjack-validation
- Owner: Rareloop
- License: mit
- Created: 2018-02-10T14:04:17.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2025-04-28T10:56:49.000Z (9 months ago)
- Last Synced: 2025-06-26T01:41:14.029Z (7 months ago)
- Language: PHP
- Size: 11.7 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Lumberjack Validation


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`:
```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
```php
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:
```php
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
}
}
}
```