File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
system/Validation/StrictRules
tests/system/Validation/StrictRules Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments