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
71
71
/**
72
72
* Greater than
73
73
*
74
- * @param mixed $str
74
+ * @param mixed $str expects int|string
75
75
*/
76
76
public function greater_than ($ str , string $ min ): bool
77
77
{
78
+ if (is_int ($ str )) {
79
+ $ str = (string ) $ str ;
80
+ }
81
+
78
82
return $ this ->nonStrictRules ->greater_than ($ str , $ min );
79
83
}
80
84
Original file line number Diff line number Diff line change @@ -106,4 +106,27 @@ public function provideGreaterThanEqualStrict(): Generator
106
106
[-1 , '0 ' , false ],
107
107
];
108
108
}
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
+ }
109
132
}
You can’t perform that action at this time.
0 commit comments