This commit is contained in:
2023-12-18 15:01:09 +08:00
parent d860269a7c
commit 645d73453c
15 changed files with 251 additions and 613 deletions
+6 -10
View File
@@ -16,18 +16,14 @@ class EmailValidator extends BaseValidator
{
/**
* @param string $field
* @param mixed $value
* @return bool
* 检查是否存在
*/
public function trigger(): bool
{
return $this->_validator($this->field, function ($field, $params) {
$value = $params[$field] ?? null;
if (!filter_var($value,FILTER_VALIDATE_EMAIL)) {
return $this->addError($field,'The param :attribute format error');
}
return true;
}, $this->params);
}
public function trigger(string $field, mixed $value): bool
{
return filter_var($value, FILTER_VALIDATE_EMAIL);
}
}