Files
kiri-validator/src/RequiredValidator.php
T

31 lines
464 B
PHP
Raw Normal View History

2021-08-11 15:13:35 +08:00
<?php
/**
* Created by PhpStorm.
* User: whwyy
* Date: 2018/4/3 0003
* Time: 15:47
*/
declare(strict_types=1);
namespace validator;
class RequiredValidator extends BaseValidator
{
/**
* @return bool
* 检查是否存在
*/
public function trigger(): bool
{
$param = $this->getParams();
2021-12-02 16:29:54 +08:00
if (!is_array($param) || !isset($param[$this->field])) {
2021-08-11 15:13:35 +08:00
return $this->addError('The param :attribute not exists');
} else {
return true;
}
}
}