Skip to content

Commit 9a6331c

Browse files
committed
fix regex for input validation
1 parent f48ae74 commit 9a6331c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

system/CLI/CLI.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ public static function promptByMultipleKeys(string $text, array $options): array
329329
// validation
330330
// return the prompt again if $input contain(s) non-numeric charachter, except a comma.
331331
while (true) {
332-
$pattern = preg_match_all('/[^0-9|^0-9,]/', trim($input));
333-
if ($pattern) {
332+
$pattern = preg_match_all('/^\d+(,\d+)*$/', trim($input));
333+
if (! $pattern) {
334334
static::error('Please select correctly.');
335335
CLI::newLine();
336336
$input = static::prompt($extraOutput) ?: 0;

0 commit comments

Comments
 (0)