Skip to content

Commit

Permalink
Fix regular expression to allow numbers ending with a zero
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Feb 4, 2025
1 parent a3f3d63 commit c72cde3
Show file tree
Hide file tree
Showing 2 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 = '/^([+]?0*)([1-9]\d*$)$/D';


/**
Expand Down
2 changes: 2 additions & 0 deletions tests/Assert/PositiveIntegerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public static function provideValidPositiveInteger(): array
{
return [
'valid positive integer' => [true, '123456'],
'valid positive ten' => [true, '30'],
'valid positive hundred' => [true, '300'],
'valid signed positive integer' => [true, '+123456'],
'valid single digit' => [true, '3'],
'valid negative leading zeros' => [true, '0000000000000000000005'],
Expand Down

0 comments on commit c72cde3

Please sign in to comment.