create-prisma-php-app 3.4.3 → 3.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -245,10 +245,10 @@ class TypeCoercer
|
|
|
245
245
|
|
|
246
246
|
private static function isArrayLike(string $value): bool
|
|
247
247
|
{
|
|
248
|
-
return Validator::json($value)
|
|
249
|
-
str_contains($value, ',')
|
|
250
|
-
str_contains($value, '[')
|
|
251
|
-
str_contains($value, '{');
|
|
248
|
+
return Validator::json($value) === true
|
|
249
|
+
|| str_contains($value, ',')
|
|
250
|
+
|| str_contains($value, '[')
|
|
251
|
+
|| str_contains($value, '{');
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
private static function getNormalizedType(mixed $value): string
|
|
@@ -328,7 +328,7 @@ class TypeCoercer
|
|
|
328
328
|
return $value;
|
|
329
329
|
}
|
|
330
330
|
if (is_string($value)) {
|
|
331
|
-
if (Validator::json($value)) {
|
|
331
|
+
if (Validator::json($value) === true) {
|
|
332
332
|
$decoded = json_decode($value, true);
|
|
333
333
|
if (is_array($decoded)) {
|
|
334
334
|
return $decoded;
|
|
@@ -284,17 +284,21 @@ final class Validator
|
|
|
284
284
|
// Other Validation
|
|
285
285
|
|
|
286
286
|
/**
|
|
287
|
-
* Validate a JSON string.
|
|
287
|
+
* Validate a JSON string or convert an array to a JSON string.
|
|
288
288
|
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
289
|
+
* This function checks if the input is a valid JSON string. If it is, it returns the string.
|
|
290
|
+
* If the input is an array, it converts it to a JSON string with specific options.
|
|
291
|
+
* If the input is invalid, it returns an error message.
|
|
292
|
+
*
|
|
293
|
+
* @param mixed $value The value to validate or convert.
|
|
294
|
+
* @return string The valid JSON string or an error message if invalid.
|
|
291
295
|
*/
|
|
292
296
|
public static function json(mixed $value): string
|
|
293
297
|
{
|
|
294
298
|
if (is_string($value)) {
|
|
295
299
|
json_decode($value);
|
|
296
300
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
|
297
|
-
|
|
301
|
+
return json_last_error_msg();
|
|
298
302
|
}
|
|
299
303
|
return $value;
|
|
300
304
|
}
|