The package is built for validating step data on the BeforeHandleStep
event of Stepped Form.
PHP: >=8.1
Laravel: ^9.0 || ^10.0
Via Composer
composer require lexal/laravel-step-validator
Add the following snippet to the bootstrap/app.php
file under the providers
section as follows:
$app->register(Lexal\LaravelStepValidator\ServiceProvider\ServiceProvider::class);
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) */,
);
}
}
Laravel & Lumen Step Validator is licensed under the MIT License. See LICENSE for the full license text.