eee
This commit is contained in:
@@ -15,9 +15,13 @@ class ArrayProxy extends TypesProxy
|
|||||||
*/
|
*/
|
||||||
public function dispatch(object $form, string $field, mixed $value): bool
|
public function dispatch(object $form, string $field, mixed $value): bool
|
||||||
{
|
{
|
||||||
if (is_null($value) && !$this->allowsNull) {
|
if (is_null($value)) {
|
||||||
|
if (!$this->allowsNull) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$form->{$field} = [];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return $value == ($form->{$field} = $value);
|
return $value == ($form->{$field} = $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,11 @@ class BoolProxy extends TypesProxy
|
|||||||
*/
|
*/
|
||||||
public function dispatch(object $form, string $field, mixed $value): bool
|
public function dispatch(object $form, string $field, mixed $value): bool
|
||||||
{
|
{
|
||||||
if (is_null($value) && !$this->allowsNull) {
|
if (is_null($value)) {
|
||||||
|
if (!$this->allowsNull) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$form->{$field} = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// TODO: Implement dispatch() method.
|
// TODO: Implement dispatch() method.
|
||||||
|
|||||||
@@ -14,7 +14,11 @@ class FloatProxy extends TypesProxy
|
|||||||
*/
|
*/
|
||||||
public function dispatch(object $form, string $field, mixed $value): bool
|
public function dispatch(object $form, string $field, mixed $value): bool
|
||||||
{
|
{
|
||||||
if (is_null($value) && !$this->allowsNull) {
|
if (is_null($value)) {
|
||||||
|
if (!$this->allowsNull) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$form->{$field} = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $value == ($form->{$field} = (float)$value);
|
return $value == ($form->{$field} = (float)$value);
|
||||||
|
|||||||
@@ -14,7 +14,11 @@ class IntProxy extends TypesProxy
|
|||||||
*/
|
*/
|
||||||
public function dispatch(object $form, string $field, mixed $value): bool
|
public function dispatch(object $form, string $field, mixed $value): bool
|
||||||
{
|
{
|
||||||
if (is_null($value) && !$this->allowsNull) {
|
if (is_null($value)) {
|
||||||
|
if (!$this->allowsNull) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$form->{$field} = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $value == ($form->{$field} = (int)$value);
|
return $value == ($form->{$field} = (int)$value);
|
||||||
|
|||||||
@@ -19,9 +19,6 @@ class MixedProxy extends TypesProxy
|
|||||||
public function dispatch(object $form, string $field, mixed $value): bool
|
public function dispatch(object $form, string $field, mixed $value): bool
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (is_null($value) && !$this->allowsNull) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return $value == ($form->{$field} = $value);
|
return $value == ($form->{$field} = $value);
|
||||||
} catch (\Throwable $throwable) {
|
} catch (\Throwable $throwable) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -15,7 +15,11 @@ class StringProxy extends TypesProxy
|
|||||||
*/
|
*/
|
||||||
public function dispatch(object $form, string $field, mixed $value): bool
|
public function dispatch(object $form, string $field, mixed $value): bool
|
||||||
{
|
{
|
||||||
if (is_null($value) && !$this->allowsNull) {
|
if (is_null($value)) {
|
||||||
|
if (!$this->allowsNull) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$form->{$field} = '';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $value == ($form->{$field} = (string)$value);
|
return $value == ($form->{$field} = (string)$value);
|
||||||
|
|||||||
@@ -120,18 +120,13 @@ class Validator
|
|||||||
foreach ($this->rules as $name => $rules) {
|
foreach ($this->rules as $name => $rules) {
|
||||||
/** @var array<array<TypesProxy,string>> $typeValidator */
|
/** @var array<array<TypesProxy,string>> $typeValidator */
|
||||||
$typeValidator = array_pop($rules);
|
$typeValidator = array_pop($rules);
|
||||||
$key = $this->alias[$name];
|
if (!isset($params[$name])) {
|
||||||
if (!isset($params[$key])) {
|
if (!empty($rules) && $rules[0] instanceof RequiredValidatorFilter) {
|
||||||
if ($rules[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 (!$typeValidator[0]->allowsNull) {
|
|
||||||
return $this->addError('The request field ' . $name . ' parameter cannot be null');
|
|
||||||
}
|
|
||||||
$params[$key] = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!call_user_func($typeValidator, $this->formData, $name, $params[$key])) {
|
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');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user