Skip to content

Commit 219e793

Browse files
committed
Fix regex for single digits
1 parent d731e36 commit 219e793

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

src/Assert/PositiveIntegerTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
trait PositiveIntegerTrait
1313
{
1414
/** @var string */
15-
private static string $positiveInteger_regex = '/^[+]?(\d+[1-9]$)$/D';
15+
private static string $positiveInteger_regex = '/^[+]?(\d*[1-9]$)$/D';
1616

1717

1818
/**

tests/Assert/PositiveIntegerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public static function providePositiveInteger(): array
4343
'empty' => [false, ''],
4444
'valid positive integer' => [true, '123456'],
4545
'valid signed positive integer' => [true, '+123456'],
46+
'valid single digit' => [true, '3'],
4647
'invalid zero' => [false, '0'],
4748
'valid negative leading zeros' => [true, '0000000000000000000005'],
4849
'invalid with fractional' => [false, '1.'],

tests/Type/PositiveIntegerValueTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public static function providePositiveInteger(): array
4545
'valid signed positive integer' => [true, '+123456'],
4646
'invalid zero' => [false, '0'],
4747
'valid negative leading zeros' => [true, '0000000000000000000005'],
48+
'valid single digit' => [true, '3'],
4849
'valid with whitespace collapse' => [true, " 1 234 \n"],
4950
'invalid with fractional' => [false, '1.'],
5051
'invalid negative' => [false, '-1234'],

0 commit comments

Comments
 (0)