lexal / laravel-step-validator
Laravel & Lumen Step validator.
v2.0.0
2023-12-28 21:38 UTC
Requires
- php: >=8.1
- illuminate/contracts: ^9.0 || ^10.0
- illuminate/support: ^9.0 || ^10.0
- lexal/stepped-form: ^2.0
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: ^1.0.0
- illuminate/http: ^10.0
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.5
- roave/security-advisories: dev-latest
- webimpress/coding-standard: ^1.3
Suggests
- illuminate/validation: Required to use step data validation on Before Handle Step event (^9.0 || ^10.0).
This package is auto-updated.
Last update: 2024-10-28 23:36:21 UTC
README
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.