modify plugin name

This commit is contained in:
2022-03-01 16:43:50 +08:00
parent e2bdf81267
commit 83e4c8a5ba
+9 -2
View File
@@ -20,8 +20,15 @@ class EnumValidator extends BaseValidator
public function trigger(): bool public function trigger(): bool
{ {
return $this->_validator($this->field, function ($field, $params, $values) { return $this->_validator($this->field, function ($field, $params, $values) {
if (!in_array($params[$field] ?? null, $values)) { $value = $params[$field] ?? null;
$message = 'The param :attribute value(' . $params[$field] . ') only in ' . implode(',', $values); if (is_null($value)) {
return true;
}
if ($value === '') {
return $this->addError($field, 'The param :attribute value con\'t empty.');
}
if (!in_array($value, $values)) {
$message = 'The param :attribute value(' . $value . ') only in ' . implode(',', $values);
return $this->addError($field, $message); return $this->addError($field, $message);
} }
return true; return true;