diff --git a/src/Validator/Types/ArrayProxy.php b/src/Validator/Types/ArrayProxy.php index 2ea2400..3aba38e 100644 --- a/src/Validator/Types/ArrayProxy.php +++ b/src/Validator/Types/ArrayProxy.php @@ -15,6 +15,9 @@ class ArrayProxy extends TypesProxy */ public function dispatch(object $form, string $field, mixed $value): bool { + if (is_null($value) && !$this->allowsNull) { + return false; + } return $value == ($form->{$field} = $value); } diff --git a/src/Validator/Types/BoolProxy.php b/src/Validator/Types/BoolProxy.php index e01ec49..dbde676 100644 --- a/src/Validator/Types/BoolProxy.php +++ b/src/Validator/Types/BoolProxy.php @@ -15,6 +15,9 @@ class BoolProxy extends TypesProxy */ public function dispatch(object $form, string $field, mixed $value): bool { + if (is_null($value) && !$this->allowsNull) { + return false; + } // TODO: Implement dispatch() method. if (in_array($value, ['false', 'true'])) { $form->{$field} = $value === 'true'; diff --git a/src/Validator/Types/FloatProxy.php b/src/Validator/Types/FloatProxy.php index 5222cc0..a32c648 100644 --- a/src/Validator/Types/FloatProxy.php +++ b/src/Validator/Types/FloatProxy.php @@ -14,6 +14,9 @@ class FloatProxy extends TypesProxy */ public function dispatch(object $form, string $field, mixed $value): bool { + if (is_null($value) && !$this->allowsNull) { + return false; + } return $value == ($form->{$field} = (float)$value); } } \ No newline at end of file diff --git a/src/Validator/Types/IntProxy.php b/src/Validator/Types/IntProxy.php index b6fa2bd..98b14b8 100644 --- a/src/Validator/Types/IntProxy.php +++ b/src/Validator/Types/IntProxy.php @@ -14,6 +14,9 @@ class IntProxy extends TypesProxy */ public function dispatch(object $form, string $field, mixed $value): bool { + if (is_null($value) && !$this->allowsNull) { + return false; + } return $value == ($form->{$field} = (int)$value); } diff --git a/src/Validator/Types/MixedProxy.php b/src/Validator/Types/MixedProxy.php index a6641d7..f7d27fe 100644 --- a/src/Validator/Types/MixedProxy.php +++ b/src/Validator/Types/MixedProxy.php @@ -19,6 +19,9 @@ class MixedProxy extends TypesProxy public function dispatch(object $form, string $field, mixed $value): bool { try { + if (is_null($value) && !$this->allowsNull) { + return false; + } return $value == ($form->{$field} = $value); } catch (\Throwable $throwable) { return false; diff --git a/src/Validator/Types/StringProxy.php b/src/Validator/Types/StringProxy.php index ba47738..a564c77 100644 --- a/src/Validator/Types/StringProxy.php +++ b/src/Validator/Types/StringProxy.php @@ -15,6 +15,9 @@ class StringProxy extends TypesProxy */ public function dispatch(object $form, string $field, mixed $value): bool { + if (is_null($value) && !$this->allowsNull) { + return false; + } return $value == ($form->{$field} = (string)$value); }