Skip to content

Commit c72cde3

Browse files
committed
Fix regular expression to allow numbers ending with a zero
1 parent a3f3d63 commit c72cde3

File tree

2 files changed

+3
-1
lines changed

2 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 = '/^([+]?0*)([1-9]\d*$)$/D';
1616

1717

1818
/**

tests/Assert/PositiveIntegerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public static function provideValidPositiveInteger(): array
4141
{
4242
return [
4343
'valid positive integer' => [true, '123456'],
44+
'valid positive ten' => [true, '30'],
45+
'valid positive hundred' => [true, '300'],
4446
'valid signed positive integer' => [true, '+123456'],
4547
'valid single digit' => [true, '3'],
4648
'valid negative leading zeros' => [true, '0000000000000000000005'],

0 commit comments

Comments
 (0)