Skip to content

Commit

Permalink
Fix regex for single digits
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Jan 18, 2025
1 parent d731e36 commit 219e793
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Assert/PositiveIntegerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
trait PositiveIntegerTrait
{
/** @var string */
private static string $positiveInteger_regex = '/^[+]?(\d+[1-9]$)$/D';
private static string $positiveInteger_regex = '/^[+]?(\d*[1-9]$)$/D';


/**
Expand Down
1 change: 1 addition & 0 deletions tests/Assert/PositiveIntegerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static function providePositiveInteger(): array
'empty' => [false, ''],
'valid positive integer' => [true, '123456'],
'valid signed positive integer' => [true, '+123456'],
'valid single digit' => [true, '3'],
'invalid zero' => [false, '0'],
'valid negative leading zeros' => [true, '0000000000000000000005'],
'invalid with fractional' => [false, '1.'],
Expand Down
1 change: 1 addition & 0 deletions tests/Type/PositiveIntegerValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static function providePositiveInteger(): array
'valid signed positive integer' => [true, '+123456'],
'invalid zero' => [false, '0'],
'valid negative leading zeros' => [true, '0000000000000000000005'],
'valid single digit' => [true, '3'],
'valid with whitespace collapse' => [true, " 1 234 \n"],
'invalid with fractional' => [false, '1.'],
'invalid negative' => [false, '-1234'],
Expand Down

0 comments on commit 219e793

Please sign in to comment.