This commit is contained in:
2023-12-12 15:35:34 +08:00
parent 26030fd148
commit d860269a7c
7 changed files with 217 additions and 218 deletions
+15 -15
View File
@@ -14,23 +14,23 @@ class RoundValidator extends BaseValidator
{
public ?int $value = null;
public ?int $value = null;
/**
* @return bool
* @throws Exception
*/
public function trigger(): bool
{
return $this->_validator($this->field, function ($field, $model, $param) {
$value = $model->getAttribute($field);
if ($value == null || round($value, $param) != $value) {
return $this->addError($field,'The param :attribute length error');
}
return true;
}, $this->model, $this->value);
}
/**
* @return bool
* @throws
*/
public function trigger(): bool
{
return $this->_validator($this->field, function ($field, $model, $param) {
$value = $model->getAttribute($field);
if ($value == null || round($value, $param) != $value) {
return $this->addError($field, 'The param :attribute length error');
}
return true;
}, $this->model, $this->value);
}
}