create-prisma-php-app 1.17.5 → 1.17.6

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.
@@ -12,20 +12,19 @@ class Validator
12
12
  /**
13
13
  * Validate and sanitize a string.
14
14
  *
15
- * This function ensures that the input is a valid string, trims any leading
16
- * or trailing whitespace, and converts special characters to HTML entities
17
- * to prevent XSS attacks. If the input is not a string, an empty string is returned.
15
+ * This function converts the input to a string, trims any leading or trailing
16
+ * whitespace, and converts special characters to HTML entities to prevent
17
+ * XSS attacks. If the input is null, an empty string is returned.
18
18
  *
19
- * @param mixed $value The value to validate and sanitize.
20
- * @return string The sanitized string or an empty string if the input is not a string.
19
+ * @param mixed $value The value to validate and sanitize. This can be of any type.
20
+ * @return string The sanitized string. If the input is not a string or null, it is converted to its string representation before sanitization. If the input is null, an empty string is returned.
21
21
  */
22
22
  public static function string($value): string
23
23
  {
24
- if (is_string($value)) {
25
- return htmlspecialchars(trim($value), ENT_QUOTES, 'UTF-8');
26
- }
27
-
28
- return '';
24
+ // Convert the value to a string if it's not null
25
+ $stringValue = $value !== null ? (string)$value : '';
26
+ // Return the HTML-escaped string
27
+ return htmlspecialchars(trim($stringValue), ENT_QUOTES, 'UTF-8');
29
28
  }
30
29
 
31
30
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "1.17.5",
3
+ "version": "1.17.6",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",