Package Data | |
---|---|
Maintainer Username: | xaamin |
Maintainer Contact: | xaamin@outlook.com (Benjamín Martínez Mateos) |
Package Create Date: | 2023-04-04 |
Package Last Update: | 2023-04-21 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-11 15:23:39 |
Package Statistics | |
---|---|
Total Downloads: | 10 |
Monthly Downloads: | 2 |
Daily Downloads: | 1 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Lumen Validation provides request validation like Laravel does using Form Requests.
This package requires requires php >= 8.0 and lumen >= 9
Step 1 - Install the package on your project
composer require xaamin/lumen-validation
Step 2 - Add the service provider in bootstrap/app.php
$app->register(
Lumen\Validation\ValidationServiceProvider::class
);
Step 3 - Extend your request from Lumen\Validation\BaseRequest
and injecting it into your controllers automatically will perform the validations. Use the authorize
method to determine if the user could access the current request.
use Lumen\Validation\BaseRequest;
class CreateUserRequest extends BaseRequest
{
protected function authorize()
{
return true;
}
protected function rules(): array
{
return [
'email' => ['required', 'string', 'unique:users'],
'name' => ['required', 'string', 'max: 200'],
];
}
}
Lumen Validation is open-sourced software licensed under the MIT license.