Revert "改名"

This reverts commit fdf58326
This commit is contained in:
2022-01-08 18:49:06 +08:00
parent 00a53ba0f3
commit 84c345375b
13 changed files with 0 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace validator;
/**
* Class EnumValidator
* @package validator
*/
class EnumValidator extends BaseValidator
{
public array $value = [];
/**
* @return bool
*/
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);
}
}