@@ -26,10 +26,10 @@ public function execute(InputInterface $input, OutputInterface $output): int
2626 $ authorQuestion = new Question ('Please enter the name of the author: ' , '' );
2727 $ authorQuestion ->setValidator (
2828 static function (string $ value ): string {
29- $ nonEmptyStringValidator = new NonEmptyStringValidator ();
29+ $ nonEmptyStringValidator = new NonEmptyStringValidator (' Author ' );
3030 $ validationResult = $ nonEmptyStringValidator ->validate ($ value );
3131 if (!$ validationResult ->isValid ) {
32- throw new RuntimeException (' Author cannot be empty ' );
32+ throw new RuntimeException ($ validationResult -> validationErrorMessage );
3333 }
3434
3535 return new StringSanitizer ()->sanitize ($ validationResult ->value );
@@ -40,10 +40,10 @@ static function (string $value): string {
4040 $ titleQuestion = new Question ('Please enter the title of the article: ' , '' );
4141 $ titleQuestion ->setValidator (
4242 static function (string $ value ): string {
43- $ nonEmptyStringValidator = new NonEmptyStringValidator ();
43+ $ nonEmptyStringValidator = new NonEmptyStringValidator (' Title ' );
4444 $ validationResult = $ nonEmptyStringValidator ->validate ($ value );
4545 if (!$ validationResult ->isValid ) {
46- throw new RuntimeException (' Title cannot be empty ' );
46+ throw new RuntimeException ($ validationResult -> validationErrorMessage );
4747 }
4848
4949 return new StringSanitizer ()->sanitize ($ validationResult ->value );
@@ -54,10 +54,10 @@ static function (string $value): string {
5454 $ urlQuestion = new Question ('Please enter the URL of the article: ' , '' );
5555 $ urlQuestion ->setValidator (
5656 static function (string $ value ): string {
57- $ nonEmptyStringValidator = new NonEmptyStringValidator ();
57+ $ nonEmptyStringValidator = new NonEmptyStringValidator (' URL ' );
5858 $ validationResult = $ nonEmptyStringValidator ->validate ($ value );
5959 if (!$ validationResult ->isValid ) {
60- throw new RuntimeException (' URL cannot be empty ' );
60+ throw new RuntimeException ($ validationResult -> validationErrorMessage );
6161 }
6262
6363 if (!filter_var ($ validationResult ->value , FILTER_VALIDATE_URL )) {
0 commit comments