Files
kiri-validator/EmailValidator.php
T

33 lines
671 B
PHP
Raw Normal View History

2022-01-09 14:01:11 +08:00
<?php
/**
* Created by PhpStorm.
* User: whwyy
* Date: 2018/4/20 0020
* Time: 17:32
*/
declare(strict_types=1);
namespace validator;
class EmailValidator extends BaseValidator
{
2023-07-07 17:24:03 +08:00
/**
* @return bool
* 检查是否存在
* @throws \ReflectionException
*/
2022-01-09 14:01:11 +08:00
public function trigger(): bool
{
2022-02-18 17:16:45 +08:00
return $this->_validator($this->field, function ($field, $params) {
$value = $params[$field] ?? null;
2023-07-07 17:24:03 +08:00
if (!filter_var($value,FILTER_VALIDATE_EMAIL)) {
return $this->addError($field,'The param :attribute format error');
}
return true;
2022-02-18 17:16:45 +08:00
}, $this->params);
2022-01-09 14:01:11 +08:00
}
}