Files
kiri-router/src/Validator/Inject/MaxLength.php
T
2023-04-15 23:31:16 +08:00

31 lines
523 B
PHP

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