Skip to content

Commit 381a445

Browse files
committed
fix: TypeError in greater_than
1 parent bc06c08 commit 381a445

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

system/Validation/StrictRules/Rules.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,14 @@ public function exact_length($str, string $val): bool
7171
/**
7272
* Greater than
7373
*
74-
* @param mixed $str
74+
* @param mixed $str expects int|string
7575
*/
7676
public function greater_than($str, string $min): bool
7777
{
78+
if (is_int($str)) {
79+
$str = (string) $str;
80+
}
81+
7882
return $this->nonStrictRules->greater_than($str, $min);
7983
}
8084

tests/system/Validation/StrictRules/RulesTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,27 @@ public function provideGreaterThanEqualStrict(): Generator
106106
[-1, '0', false],
107107
];
108108
}
109+
110+
/**
111+
* @dataProvider provideGreaterThanStrict
112+
*
113+
* @param int $value
114+
*/
115+
public function testGreaterThanStrict($value, string $param, bool $expected): void
116+
{
117+
$this->validation->setRules(['foo' => "greater_than[{$param}]"]);
118+
119+
$data = ['foo' => $value];
120+
$this->assertSame($expected, $this->validation->run($data));
121+
}
122+
123+
public function provideGreaterThanStrict(): Generator
124+
{
125+
yield from [
126+
[-10, '-11', true],
127+
[10, '9', true],
128+
[10, '10', false],
129+
[10, 'a', false],
130+
];
131+
}
109132
}

0 commit comments

Comments
 (0)