This commit is contained in:
2023-12-18 02:56:19 +08:00
parent 0df48062ac
commit 24b185bf21
+3 -1
View File
@@ -118,10 +118,12 @@ class Validator
/** @var array<array<TypesProxy,string>> $typeValidator */ /** @var array<array<TypesProxy,string>> $typeValidator */
$typeValidator = array_pop($rules); $typeValidator = array_pop($rules);
if (!isset($params[$name])) { if (!isset($params[$name])) {
if (!empty($rules) && $rules[0] instanceof RequiredValidatorFilter) { if (isset($rules[0])) {
if ($rules[0][0] instanceof RequiredValidatorFilter) {
return $this->addError('The request field ' . $name . ' is mandatory and indispensable'); return $this->addError('The request field ' . $name . ' is mandatory and indispensable');
} }
} }
}
if (!call_user_func($typeValidator, $this->formData, $name, $params[$name] ?? null)) { if (!call_user_func($typeValidator, $this->formData, $name, $params[$name] ?? null)) {
return $this->addError('The parameter type used in the request field ' . $name . ' is incorrect'); return $this->addError('The parameter type used in the request field ' . $name . ' is incorrect');