From 7384abd4074caeb3f5bb14a409f31c3f951ab9f1 Mon Sep 17 00:00:00 2001
From: Merel Theisen <49397448+merelcht@users.noreply.github.com>
Date: Wed, 24 Jan 2024 18:28:52 +0000
Subject: [PATCH] Improve error message for invalid example pipeline value
 (#3543)

Signed-off-by: Merel Theisen <merel.theisen@quantumblack.com>
---
 kedro/framework/cli/starters.py      |  4 ++--
 kedro/templates/project/prompts.yml  |  2 +-
 tests/framework/cli/test_starters.py | 13 ++++++++++---
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/kedro/framework/cli/starters.py b/kedro/framework/cli/starters.py
index 5f364fe36b..5ec32af209 100644
--- a/kedro/framework/cli/starters.py
+++ b/kedro/framework/cli/starters.py
@@ -153,11 +153,11 @@ def _validate_input_with_regex_pattern(pattern_name: str, input: str) -> None:
     VALIDATION_PATTERNS = {
         "yes_no": {
             "regex": r"(?i)^\s*(y|yes|n|no)\s*$",
-            "error_message": "|It must contain only y, n, YES, NO, case insensitive.",
+            "error_message": f"'{input}' is an invalid value for example pipeline. It must contain only y, n, YES, or NO (case insensitive).",
         },
         "project_name": {
             "regex": r"^[\w -]{2,}$",
-            "error_message": f"{input}' is an invalid value for project name. It must contain only alphanumeric symbols, spaces, underscores and hyphens and be at least 2 characters long",
+            "error_message": f"'{input}' is an invalid value for project name. It must contain only alphanumeric symbols, spaces, underscores and hyphens and be at least 2 characters long",
         },
         "tools": {
             "regex": r"""^(
diff --git a/kedro/templates/project/prompts.yml b/kedro/templates/project/prompts.yml
index 9f29069f43..c6f8608b28 100644
--- a/kedro/templates/project/prompts.yml
+++ b/kedro/templates/project/prompts.yml
@@ -40,4 +40,4 @@ example_pipeline:
     Would you like to include an example pipeline? [y/N]:
   regex_validator: "(?i)^(y|yes|n|no)$"
   error_message: |
-    It must contain only y, n, YES, NO, case insensitive.
+    It must contain only y, n, YES, or NO (case insensitive).
diff --git a/tests/framework/cli/test_starters.py b/tests/framework/cli/test_starters.py
index 35e010ae40..d89270f862 100644
--- a/tests/framework/cli/test_starters.py
+++ b/tests/framework/cli/test_starters.py
@@ -1133,9 +1133,12 @@ def test_invalid_example(self, fake_kedro_cli, bad_input):
         )
 
         assert result.exit_code != 0
-        assert "is an invalid value for example pipeline." in result.output
         assert (
-            "It must contain only y, n, YES, NO, case insensitive.\n" in result.output
+            f"'{bad_input}' is an invalid value for example pipeline." in result.output
+        )
+        assert (
+            "It must contain only y, n, YES, or NO (case insensitive).\n"
+            in result.output
         )
 
 
@@ -1311,7 +1314,11 @@ def test_invalid_example(self, fake_kedro_cli, bad_input):
 
         assert result.exit_code != 0
         assert (
-            "It must contain only y, n, YES, NO, case insensitive.\n" in result.output
+            f"'{bad_input}' is an invalid value for example pipeline." in result.output
+        )
+        assert (
+            "It must contain only y, n, YES, or NO (case insensitive).\n"
+            in result.output
         )