Skip to content

Commit 47c9093

Browse files
committed
bug #587 change from-email-address default value to empty string (IndraGunawan)
This PR was squashed before being merged into the 1.0-dev branch. Discussion ---------- change from-email-address default value to empty string when create a reset-password at question `What email address will be used to send reset confirmations? e.g. [email protected]` and we just enter without filling the answer it will thrown an exception ``` Argument 1 passed to Symfony\Bundle\MakerBundle\Validator::validateEmailAddress() must be of the type string, null given, called in /path/vendor/symfony/console/Helper/QuestionHelper.php on line 468 ``` there are 2 possible solution. 1. change the default value to empty string (this PR), or 2. make the `validateEmailAddress` argument nullable and check the value inside the method. Commits ------- 698f566 change from-email-address default value to empty string
2 parents 5e8dab5 + 698f566 commit 47c9093

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public static function validateDoctrineFieldName(string $name, ManagerRegistry $
167167
return $name;
168168
}
169169

170-
public static function validateEmailAddress(string $email): string
170+
public static function validateEmailAddress(?string $email): string
171171
{
172172
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
173173
throw new RuntimeCommandException(sprintf('"%s" is not a valid email address.', $email));

tests/ValidatorTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,17 @@ public function testValidateClassName()
6868
public function testValidateEmailAddress()
6969
{
7070
$this->assertSame('[email protected]', Validator::validateEmailAddress('[email protected]'));
71+
}
7172

73+
public function testInvalidateEmailAddress()
74+
{
7275
$this->expectException(RuntimeCommandException::class);
7376
$this->expectExceptionMessage('"badEmail" is not a valid email address.');
7477
Validator::validateEmailAddress('badEmail');
78+
79+
$this->expectException(RuntimeCommandException::class);
80+
$this->expectExceptionMessage('"" is not a valid email address.');
81+
Validator::validateEmailAddress('');
7582
}
7683

7784
public function testInvalidClassName()

0 commit comments

Comments
 (0)