# herosphp-validate **Repository Path**: blackfox/herosphp-validate ## Basic Information - **Project Name**: herosphp-validate - **Description**: herosphp 验证器插件 - **Primary Language**: PHP - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-09-20 - **Last Updated**: 2022-09-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # herosphp/validate 在中间件上进行验证 ### install ```shell composer install herosphp/validate ``` ### usage 在中间件层验证参数是正确 ```php getAttributes(Valid::class); if ($reflectionAttributes) { foreach ($reflectionAttributes as $validAttribute) { /** @var Valid $methodValidInstance */ $methodValidInstance = $validAttribute->newInstance(); $methodVInstance = new ($methodValidInstance->class); if (!$methodVInstance instanceof Validate) { throw new ValidateException("{$methodVInstance->class} must extend \\herosphp\\plugin\\validate\Validate"); } $methodVInstance->scene($methodValidInstance->scene)->check([...$request->get(), ...$request->post()]); } } return $handler($request); } } ```