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