Skip to content

Commit ac773ed

Browse files
committed
Validation preg_match() second argument type error fixed.
1 parent a7164da commit ac773ed

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/Validation/ValidationRulesTrait.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,39 +48,39 @@ protected function required($data): bool
4848

4949
protected function string($data): bool
5050
{
51-
return (bool)\preg_match('/[\S]+/', $data);
51+
return (bool)\preg_match('/[\S]+/', (string)$data);
5252
}
5353

5454
protected function int($data): bool
5555
{
56-
return (bool)\preg_match('/^([+|\-]*)[0-9]+$/', $data);
56+
return (bool)\preg_match('/^([+|\-]*)[0-9]+$/', (string)$data);
5757
}
5858

5959
protected function float($data): bool
6060
{
61-
return (bool)\preg_match('/^[+|\-]*[0-9]+[.]+[0-9]+$/', $data);
61+
return (bool)\preg_match('/^[+|\-]*[0-9]+[.]+[0-9]+$/', (string)$data);
6262
}
6363

6464
protected function numeric($data):bool
6565
{
66-
return (bool)\preg_match('/^[+|\-]*[0-9]+([.]+[0-9]+)*$/', $data);
66+
return (bool)\preg_match('/^[+|\-]*[0-9]+([.]+[0-9]+)*$/', (string)$data);
6767
}
6868

6969
protected function alpha($data): bool
7070
{
7171
$pattern = '[a-zA-ZğĞŞşÜüİıÖöÇç]';
72-
return (bool)\preg_match('/^' . $pattern . '$/', $data);
72+
return (bool)\preg_match('/^' . $pattern . '$/', (string)$data);
7373
}
7474

7575
protected function alphaNumeric($data): bool
7676
{
7777
$pattern = '(?:([+|\-]*[0-9]+([.]+[0-9]+)*)|([0-9a-zA-ZğĞŞşÜüİıÖöÇç]))+';
78-
return (bool)\preg_match('/^' . $pattern . '$/', $data);
78+
return (bool)\preg_match('/^' . $pattern . '$/', (string)$data);
7979
}
8080

8181
protected function boolean($data): bool
8282
{
83-
return (bool)\preg_match('/^(true|false|0|1)]+$/', $data);
83+
return (bool)\preg_match('/^(true|false|0|1)]+$/', (string)$data);
8484
}
8585

8686
protected function mail($data): bool
@@ -120,7 +120,7 @@ protected function range($data, $min = \PHP_INT_MIN, $max = \PHP_INT_MAX)
120120

121121
protected function regex($data, $pattern): bool
122122
{
123-
return (bool)\preg_match($pattern, $data);
123+
return (bool)\preg_match($pattern, (string)$data);
124124
}
125125

126126
protected function ip($data): bool
@@ -161,7 +161,7 @@ protected function strContains($data, $search): bool
161161
protected function only($data, ...$only): bool
162162
{
163163
foreach ($only as $row) {
164-
if($row === $data){
164+
if($row == $data){
165165
return true;
166166
}
167167
}

0 commit comments

Comments
 (0)