[PHP-WEBMASTER] [web-downloads] main: Add null check in Validator::regex
[email protected] (Shivam Mathur) Thu, 2 Apr 2026 01:27:58 +0000
| Newsgroups | php.webmaster |
|---|---|
| Message-ID | <[email protected]> |
Author: Shivam Mathur (shivammathur)
Date: 2026-04-02T06:12:30+05:30
Commit: https://github.com/php/web-downloads/commit/df12651064b012cd0c9324a53affc0ee36280d28
Raw diff: https://github.com/php/web-downloads/commit/df12651064b012cd0c9324a53affc0ee36280d28.diff
Add null check in Validator::regex
Changed paths:
M src/Validator.php
Diff:
diff --git a/src/Validator.php b/src/Validator.php
index 298cbd8..164720f 100644
--- a/src/Validator.php
+++ b/src/Validator.php
@@ -82,7 +82,7 @@ protected function string($value): bool
protected function regex($value, $pattern): bool
{
- return preg_match($pattern, $value) === 1;
+ return is_string($value) && preg_match($pattern, $value) === 1;
}
protected function getErrorMessage($field, $rule, $value): string