From 68038fb6c29c6e0aacc7cb9cbc59e85ae64716a1 Mon Sep 17 00:00:00 2001 From: Daniel Ronkainen Date: Mon, 13 Apr 2026 20:25:41 +0200 Subject: [PATCH] fix: add data type check before json string starts validate --- src/ValidationChain.php | 3 ++- src/Validator.php | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ValidationChain.php b/src/ValidationChain.php index 75e74a6..610459b 100644 --- a/src/ValidationChain.php +++ b/src/ValidationChain.php @@ -216,7 +216,7 @@ class ValidationChain private array $error = []; private array $errorArgs = []; - /** + /** * Constructor for the ValidationChain class. * * @param mixed $value The initial value to be validated. @@ -440,4 +440,5 @@ public function validate(?string $description = null): void { $this->describe($description); } + } diff --git a/src/Validator.php b/src/Validator.php index 48045b3..cb9affa 100755 --- a/src/Validator.php +++ b/src/Validator.php @@ -567,6 +567,9 @@ public function isResource(): bool */ public function isJson(): bool { + if(!is_string($this->value) && !is_numeric($this->value)) { + return false; + } json_decode($this->value); return json_last_error() === JSON_ERROR_NONE; }