lexal / laravel-step-validator
Laravel & Lumen 步骤验证器。
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-09-28 23:16:44 UTC
README
该包用于在Stepped Form的BeforeHandleStep
事件上验证步骤数据。
要求
PHP >=8.1
Laravel ^9.0 || ^10.0
安装
通过Composer
composer require lexal/laravel-step-validator
Lumen框架的附加更改
将以下片段添加到bootstrap/app.php
文件中的 providers 部分,如下所示
$app->register(Lexal\LaravelStepValidator\ServiceProvider\ServiceProvider::class);
用法
为步骤实现ValidatableStepInterface
,监听器将在处理步骤之前验证步骤数据。验证器将直接将RulesDefinition
数据传递给Laravel验证器工厂方法。
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遵循MIT许可证。有关完整的许可文本,请参阅LICENSE。