modify plugin name
This commit is contained in:
+10
-19
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace validator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Class EnumValidator
|
||||
* @package validator
|
||||
@@ -20,24 +19,16 @@ class EnumValidator extends BaseValidator
|
||||
*/
|
||||
public function trigger(): bool
|
||||
{
|
||||
if (empty($this->params) || !isset($this->params[$this->field])) {
|
||||
return $this->addError('The param :attribute is null');
|
||||
}
|
||||
if (is_null($this->params[$this->field])) {
|
||||
return $this->addError('The param :attribute is null');
|
||||
}
|
||||
if (!in_array($this->params[$this->field], $this->value)) {
|
||||
return $this->addError($this->i());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function i(): string
|
||||
{
|
||||
return 'The param :attribute value only in ' . implode(',', $this->value);
|
||||
return $this->_validator($this->field, function ($field, $params, $values) {
|
||||
$value = $params[$field] ?? null;
|
||||
if (empty($value)) {
|
||||
return $this->addError('The param :attribute is null');
|
||||
}
|
||||
if (!in_array($value, $values)) {
|
||||
return $this->addError('The param :attribute value only in ' . implode(',', $values));
|
||||
}
|
||||
return true;
|
||||
}, $this->params, $this->value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user