File tree Expand file tree Collapse file tree 4 files changed +10
-5
lines changed
Expand file tree Collapse file tree 4 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ public function isValid(mixed $value): bool
2020 return true ;
2121 }
2222
23+ if ($ value === null || $ value === false || $ value === '' ) {
24+ return false ;
25+ }
26+
2327 if (floatval ($ value ) == $ value ) {
2428 return true ;
2529 }
Original file line number Diff line number Diff line change @@ -20,11 +20,7 @@ public function isValid(mixed $value): bool
2020 return true ;
2121 }
2222
23- if ($ value === null ) {
24- return false ;
25- }
26-
27- if ($ value === '' ) {
23+ if ($ value === null || $ value === false || $ value === '' ) {
2824 return false ;
2925 }
3026
Original file line number Diff line number Diff line change @@ -20,5 +20,8 @@ public function test_float(): void
2020 $ this ->assertTrue ($ rule ->isValid (0.1 ));
2121 $ this ->assertTrue ($ rule ->isValid ('0.1 ' ));
2222 $ this ->assertFalse ($ rule ->isValid ('a ' ));
23+ $ this ->assertFalse ($ rule ->isValid ('' ));
24+ $ this ->assertFalse ($ rule ->isValid (null ));
25+ $ this ->assertFalse ($ rule ->isValid (false ));
2326 }
2427}
Original file line number Diff line number Diff line change @@ -20,5 +20,7 @@ public function test_integer(): void
2020 $ this ->assertTrue ($ rule ->isValid ('1 ' ));
2121 $ this ->assertFalse ($ rule ->isValid ('a ' ));
2222 $ this ->assertFalse ($ rule ->isValid ('' ));
23+ $ this ->assertFalse ($ rule ->isValid (null ));
24+ $ this ->assertFalse ($ rule ->isValid (false ));
2325 }
2426}
You can’t perform that action at this time.
0 commit comments