A request validation package based on laravel validation and larammerce annotation parser.

1.0.3 2019-07-13 19:33 UTC

This package is auto-updated.

Last update: 2020-11-13 22:46:06 UTC


Build Status

A modern validation package for laravel apps, based on laravel validation and larammerce/annotation-parser package.


composer require larammerce/validation


  • First you need to publish configuration file for this project.
php artisan vendor:publish --provider="Larammerce\Validation\ValidationServiceProvider"
  • Then customise the config file if needed.
return [
    "annotation_name" => "my_rules", // the rules will be read from @my_rules annotation.
    "dynamic_rules_key" => "dynamic_rules" // dynamic rules (described in docs) will be read from dynamic_rules key.
  • Add Larammerce\Validation\Middleware\RulesMiddleware::class to your route or group of routes as middleware directly, or you can add it to $routeMiddleware in /app/Http/Kernel.php file.
//Kernel.php file.
protected $routeMiddleware = [
    "rules" => Larammerce\Validation\Middleware\RulesMiddleware::class
//routes/web.php | routes/api.php file.
Route::get("/test-route", "App\Http\Controllers\HomeController@main")->middleware("rules");
class HomeController extends Controller {
     * @my_rules(title="required", dynamic_rules=App\Http\Controllers\HomeController::dynamicRules(request("title")))
    public function main(Request $request){
        return "Hello";

    public static function dynamicRules($title){
        //conditional rules according to passed data.
        return [
            $title."_input" => "required"