Skip to content

Commit 0939d4b

Browse files
committed
Relax QuestionContentSchema input_type to accept any identifier
Same change as InteractionCreate — flow authors can define custom question input types without needing API schema changes.
1 parent 0b7a109 commit 0939d4b

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

app/services/node_input_validation.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,24 +102,16 @@ def validate_messages(cls, v):
102102
class QuestionContentSchema(BaseModel):
103103
"""Validation schema for question node content.
104104

105-
Supported input types:
106-
- text: Free text input
107-
- number: Numeric input with optional min/max
108-
- email: Email address input
109-
- phone: Phone number input
110-
- url: URL input
111-
- date: Date picker
112-
- choice: Single selection from options (buttons/radio)
113-
- multiple_choice: Multiple selection from options (checkboxes)
114-
- slider: Range slider (for age, ratings, scales)
115-
- image_choice: Single selection from image-based options (for visual preference questions)
116-
- carousel: Swipeable carousel for browsing items (e.g., books)
105+
input_type must be a lowercase identifier (e.g. text, choice, book_feedback).
106+
Common built-in types: text, number, email, phone, url, date, choice,
107+
multiple_choice, slider, image_choice, carousel. Flow authors can define
108+
custom input types without schema changes.
117109
"""
118110

119111
question: Dict[str, Any] = Field(...)
120112
input_type: str = Field(
121113
...,
122-
pattern=r"^(text|choice|multiple_choice|number|email|phone|url|date|slider|image_choice|carousel)$",
114+
pattern=r"^[a-z][a-z0-9_]{0,49}$",
123115
)
124116
options: Optional[List[Dict[str, Any]]] = None
125117
validation: Optional[Dict[str, Any]] = None

app/tests/unit/test_node_input_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def test_question_node_validation_invalid_input_type(self):
115115
"""Test question node validation fails with invalid input type."""
116116
content = {
117117
"question": {"text": "Enter something"},
118-
"input_type": "invalid_type", # Not in allowed pattern
118+
"input_type": "123-INVALID!", # Not a valid identifier
119119
}
120120

121121
report = self.validator.validate_node(self.node_id, NodeType.QUESTION, content)

0 commit comments

Comments
 (0)