Files
kiri-router/src/Validator/Inject/MaxLength.php
T

31 lines
523 B
PHP
Raw Normal View History

2023-04-15 23:29:27 +08:00
<?php
2023-04-15 23:31:16 +08:00
namespace Kiri\Router\Validator\Inject;
use Kiri\Router\Interface\ValidatorInterface;
2023-04-15 23:29:27 +08:00
#[\Attribute(\Attribute::TARGET_PROPERTY)]
class MaxLength implements ValidatorInterface
{
/**
* @param int $value
*/
public function __construct(readonly public int $value)
{
}
/**
2023-04-15 23:31:16 +08:00
* @param object $class
2023-04-15 23:29:27 +08:00
* @param string $name
* @return bool
*/
2023-04-15 23:31:16 +08:00
public function dispatch(object $class, string $name): bool
2023-04-15 23:29:27 +08:00
{
// TODO: Implement dispatch() method.
2023-04-15 23:31:16 +08:00
return mb_strlen($class->{$name}) <= $this->value;
2023-04-15 23:29:27 +08:00
}
}