Skip to content

Commit 422d5e9

Browse files
committed
Allow decrement to work with negative numbers
1 parent 03c371a commit 422d5e9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Input/Number.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function ask() : InputResult
9292

9393
public function validate(string $input) : bool
9494
{
95-
return (bool) preg_match('/^\d+$/', $input);
95+
return (bool) preg_match('/^-?\d+$/', $input);
9696
}
9797

9898
public function filter(string $value) : string

test/Input/NumberTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ public function validateProvider() : array
8080
['0', true],
8181
['0000000000', true],
8282
['9999999999', true],
83+
['-9999999999', true],
84+
['-54', true],
85+
['-1', true],
86+
['-t10', false],
87+
['-t', false],
8388
];
8489
}
8590

0 commit comments

Comments
 (0)