8000 fix: validateJson should return false when value is null · Xint0/laravel-framework@fbe882d · GitHub
[go: up one dir, main page]

Skip to content

Commit fbe882d

Browse files
committed
fix: validateJson should return false when value is null
Return false when $value is null. Avoid TypeError: json_validate(): Argument laravel#1 ($json) must be of type string, null given, when using symfony/polyfill-php83 in PHP < 8.3. Avoid deprecation warning: json_validate(): Passing null to parameter laravel#1 ($json) of type string is deprecated, when using PHP 8.3.
1 parent cb19e13 commit fbe882d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Illuminate/Validation/Concerns/ValidatesAttributes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,11 +1430,11 @@ public function validateMacAddress($attribute, $value)
14301430
*/
14311431
public function validateJson($attribute, $value)
14321432
{
1433-
if (is_array($value)) {
1433+
if (is_array($value) || is_null($value)) {
14341434
return false;
14351435
}
14361436

1437-
if (! is_scalar($value) && ! is_null($value) && ! method_exists($value, '__toString')) {
1437+
if (! is_scalar($value) && ! method_exists($value, '__toString')) {
14381438
return false;
14391439
}
14401440

0 commit comments

Comments
 (0)
0