Skip to content

lexalium/laravel-step-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Step Validator for Laravel & Lumen

PHPUnit, PHPCS, PHPStan Tests

The package is built for validating step data on the BeforeHandleStep event of Stepped Form.

Requirements

PHP: >=8.1

Laravel: ^9.0 || ^10.0

Installation

Via Composer

composer require lexal/laravel-step-validator

Additional changes for Lumen framework

Add the following snippet to the bootstrap/app.php file under the providers section as follows:

$app->register(Lexal\LaravelStepValidator\ServiceProvider\ServiceProvider::class);

Usage

Implement ValidatableStepInterface for the step and the listener will validate step data before handling the step. The validator will pass RulesDefinition data directly to the Laravel validator factory method.

use Lexal\LaravelStepValidator\RulesDefinition;
use Lexal\LaravelStepValidator\Steps\ValidatableStepInterface;
use Lexal\SteppedForm\Steps\RenderStepInterface;

final class CustomerStep implements RenderStepInterface, ValidatableStepInterface
{
    public function getRulesDefinition(mixed $entity): RulesDefinition
    {
        return new RulesDefinition(
            /* rules */,
            /* messages (default - empty array) */,
            /* custom attributes (default - empty array) */,
        );
    }
}

License

Laravel & Lumen Step Validator is licensed under the MIT License. See LICENSE for the full license text.

About

The package is built for validating step data on the BeforeHandleStep event.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages