Skip to content

Commit 8d0b538

Browse files
committed
refactored email address question to use email address validator
1 parent fe669bf commit 8d0b538

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/Maker/MakeResetPassword.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use Symfony\Component\Console\Command\Command;
2424
use Symfony\Component\Console\Input\InputArgument;
2525
use Symfony\Component\Console\Input\InputInterface;
26-
use Symfony\Component\Console\Question\Question;
2726
use SymfonyCasts\Bundle\ResetPassword\SymfonyCastsResetPasswordBundle;
2827

2928
class MakeResetPassword extends AbstractMaker
@@ -83,21 +82,12 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
8382
$emailText[] = 'You can change these later after the templates have been generated.';
8483
$io->text($emailText);
8584

86-
$emailAddressQuestion = new Question('What email address will be used to send reset confirmations? I.e. [email protected]');
87-
$emailAddressQuestion->setValidator(
88-
static function ($answer) {
89-
// @TODO - In maker-bundle PR, introduce new native Validator::emailAddress()...
90-
$validatedAnswer = filter_var($answer, FILTER_VALIDATE_EMAIL);
91-
92-
if (!$validatedAnswer) {
93-
throw new RuntimeCommandException(sprintf('"%s" is not a valid email address.', $answer));
94-
}
95-
96-
return $validatedAnswer;
97-
}
98-
);
85+
$input->setArgument('from-email-address', $io->ask(
86+
'What email address will be used to send reset confirmations? I.e. [email protected]',
87+
null,
88+
[Validator::class, 'validateEmailAddress']
89+
));
9990

100-
$input->setArgument('from-email-address', $io->askQuestion($emailAddressQuestion));
10191
$input->setArgument('from-email-name', $io->ask(
10292
'What name will be associated with the email address used to send password reset confirmations? I.e. John Doe or Your Company, LLC.',
10393
null,

0 commit comments

Comments
 (0)