eee
This commit is contained in:
+8
-24
@@ -19,7 +19,6 @@ class TypesOfValidator extends BaseValidator
|
||||
const ARRAY = 'array';
|
||||
const STRING = 'string';
|
||||
const INTEGER = 'integer';
|
||||
const SERIALIZE = 'serialize';
|
||||
|
||||
private ?int $min = null;
|
||||
private ?int $max = null;
|
||||
@@ -30,8 +29,7 @@ class TypesOfValidator extends BaseValidator
|
||||
self::FLOAT => 'float',
|
||||
self::ARRAY => 'array',
|
||||
self::STRING => 'string',
|
||||
self::INTEGER => 'integer',
|
||||
self::SERIALIZE => 'serialize',
|
||||
self::INTEGER => 'integer'
|
||||
];
|
||||
|
||||
/** @var string */
|
||||
@@ -48,8 +46,13 @@ class TypesOfValidator extends BaseValidator
|
||||
return true;
|
||||
}
|
||||
$value = $params[$field] ?? null;
|
||||
|
||||
return $this->{$method . 'Format'}($field, $value);
|
||||
return match ($method) {
|
||||
self::INTEGER => $this->integerFormat($field, $value),
|
||||
self::FLOAT => $this->floatFormat($field, $value),
|
||||
self::JSON => $this->jsonFormat($field, $value),
|
||||
self::STRING => $this->stringFormat($field, $value),
|
||||
self::ARRAY => $this->arrayFormat($field, $value),
|
||||
};
|
||||
}, $this->params, $this->method, $this->types);
|
||||
}
|
||||
|
||||
@@ -57,7 +60,6 @@ class TypesOfValidator extends BaseValidator
|
||||
* @param $field
|
||||
* @param $value
|
||||
* @return bool
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function jsonFormat($field, $value): bool
|
||||
{
|
||||
@@ -71,21 +73,6 @@ class TypesOfValidator extends BaseValidator
|
||||
* @param $field
|
||||
* @param $value
|
||||
* @return bool
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function serializeFormat($field, $value): bool
|
||||
{
|
||||
if (false === unserialize($value)) {
|
||||
return $this->addError($field, 'The ' . $field . ' not is serialize data.');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $field
|
||||
* @param $value
|
||||
* @return bool
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function arrayFormat($field, $value): bool
|
||||
{
|
||||
@@ -99,7 +86,6 @@ class TypesOfValidator extends BaseValidator
|
||||
* @param $field
|
||||
* @param $value
|
||||
* @return bool
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function stringFormat($field, $value): bool
|
||||
{
|
||||
@@ -113,7 +99,6 @@ class TypesOfValidator extends BaseValidator
|
||||
* @param $field
|
||||
* @param $value
|
||||
* @return bool
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function integerFormat($field, $value): bool
|
||||
{
|
||||
@@ -127,7 +112,6 @@ class TypesOfValidator extends BaseValidator
|
||||
* @param $field
|
||||
* @param $value
|
||||
* @return bool
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function floatFormat($field, $value): bool
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user