Skip to content

Commit e5fbc01

Browse files
authored
Merge pull request #17 from maplephp/develop
Add data type check before json string starts validate
2 parents 68913e7 + 68038fb commit e5fbc01

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/ValidationChain.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class ValidationChain
216216
private array $error = [];
217217
private array $errorArgs = [];
218218

219-
/**
219+
/**
220220
* Constructor for the ValidationChain class.
221221
*
222222
* @param mixed $value The initial value to be validated.
@@ -440,4 +440,5 @@ public function validate(?string $description = null): void
440440
{
441441
$this->describe($description);
442442
}
443+
443444
}

src/Validator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,9 @@ public function isResource(): bool
567567
*/
568568
public function isJson(): bool
569569
{
570+
if(!is_string($this->value) && !is_numeric($this->value)) {
571+
return false;
572+
}
570573
json_decode($this->value);
571574
return json_last_error() === JSON_ERROR_NONE;
572575
}

0 commit comments

Comments
 (0)