Skip to content

Commit

Permalink
fix: validateJson should return false when value is null
Browse files Browse the repository at this point in the history
Return false when $value is null.

Avoid TypeError: json_validate(): Argument #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 #1 ($json) of type string is deprecated, when using PHP 8.3.
  • Loading branch information
Xint0-elab committed Dec 22, 2023
1 parent cb19e13 commit fbe882d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -1430,11 +1430,11 @@ public function validateMacAddress($attribute, $value)
*/
public function validateJson($attribute, $value)
{
if (is_array($value)) {
if (is_array($value) || is_null($value)) {
return false;
}

if (! is_scalar($value) && ! is_null($value) && ! method_exists($value, '__toString')) {
if (! is_scalar($value) && ! method_exists($value, '__toString')) {
return false;
}

Expand Down

0 comments on commit fbe882d

Please sign in to comment.