Files
kiri-validator/RoundValidator.php
T
as2252258 84c345375b Revert "改名"
This reverts commit fdf58326
2022-01-08 18:49:06 +08:00

35 lines
471 B
PHP

<?php
namespace validator;
use Exception;
/**
* Class RoundValidator
* @package validator
*/
class RoundValidator extends BaseValidator
{
public ?int $value = null;
/**
* @return bool
* @throws Exception
*/
public function trigger(): bool
{
$value = $this->model->getAttribute($this->field);
if ($value == null || round($value, $this->value) != $value) {
return $this->addError('The param :attribute length error');
}
return true;
}
}