Package Data | |
---|---|
Maintainer Username: | rewake |
Maintainer Contact: | r.komatz@gmail.com (Richard Komatz) |
Package Create Date: | 2019-10-31 |
Package Last Update: | 2024-11-06 |
Language: | PHP |
License: | proprietary |
Last Refreshed: | 2024-12-15 15:22:32 |
Package Statistics | |
---|---|
Total Downloads: | 7 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 1 |
NOTE: This package is for Lumen v6. For Lumen v5 use https://github.com/rewake/lumen-validation
This library provides enhancements to the illuminate/validation
package which will validate objects and classes
instead of arrays "only". The default Lumen validator has been wrapped so that all existing validation functionality
should be available, however this is not yet fully tested.
A ValidationRuleInterface
is also provided so that validation rules may be classified for ease of use and code
separation.
A Service Provider is included to make registering the Validation Service easy from app.php
config.
$app->register(Rewake\Lumen\Providers\ValidationServiceProvider::class);
NOTE:
This Service Provider will override the default app('validator')
alias within lumen, and is currently not tested
fully. If you would like to keep them separate (or need to keep them separate), you can create a new Provider to do
so.
public function register()
{
// Register Validation Service
$this->app->singleton(
'validation_service',
\Rewake\Lumen\Services\ValidationService::class
);
}
<?php
namespace App\Validation;
use Rewake\Lumen\Validation\ValidationRuleInterface;
class ExampleValidation implements ValidationRuleInterface
{
public static function descriptor()
{
return [];
}
public static function rules()
{
return [
"first" => [
'required',
'string'
],
"last" => [
'required',
'string'
],
"id" => [
'required',
'integer'
]
];
}
public static function messages()
{
return [];
}
}
app('validator')->validate($data, ExampleValidation::class);