eee
This commit is contained in:
+4
-12
@@ -12,22 +12,14 @@ namespace validator;
|
||||
class EnumValidator extends BaseValidator
|
||||
{
|
||||
|
||||
public array $value = [];
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function trigger(): bool
|
||||
public function trigger(string $field, mixed $value): bool
|
||||
{
|
||||
return $this->_validator($this->field, function ($field, $params, $values) {
|
||||
$value = $params[$field] ?? null;
|
||||
if (in_array($value, $values)) {
|
||||
return true;
|
||||
}
|
||||
$message = 'The param :attribute value(' . $value . ') only in ' . implode(',', $values);
|
||||
return $this->addError($field, $message);
|
||||
|
||||
}, $this->params, $this->value);
|
||||
return in_array($value, $this->value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user