This commit is contained in:
xl
2023-11-09 22:08:24 +08:00
parent 1112341e3f
commit 0db2958351
18 changed files with 121 additions and 297 deletions
+7 -21
View File
@@ -3,22 +3,13 @@ declare(strict_types=1);
namespace Kiri\Router\Validator\Inject;
use Kiri\Di\Inject\Container;
use Kiri\Router\Interface\ValidatorInterface;
use Psr\Http\Message\RequestInterface;
#[\Attribute(\Attribute::TARGET_PROPERTY)]
class In implements ValidatorInterface
{
/**
* @var RequestInterface
*/
#[Container(RequestInterface::class)]
public RequestInterface $request;
/**
* @param array $value
*/
@@ -27,18 +18,13 @@ class In implements ValidatorInterface
}
/**
* @param object $class
* @param string $name
* @return bool
*/
public function dispatch(object $class, string $name): bool
{
if ($this->request->getIsPost()) {
$data = $this->request->post($name, null);
} else {
$data = $this->request->query($name, null);
}
/**
* @param mixed $data
* @param object $class
* @return bool
*/
public function dispatch(mixed $data, object $class): bool
{
if ($data === null) {
return false;
}