Every entry in theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/apursley2012/alex-pizza-assistant/llms.txt
Use this file to discover all available pages before exploring further.
steps[] array carries two properties that make the form self-enforcing: a validate() function and an error string. When the user submits an answer, handleSubmit() calls step.validate(rawValue) before doing anything else. If the validator returns false, the error string is written to the #validationMessage element and the current step does not advance — the user must correct their input and try again. Only a passing validation clears the message, saves the answer, and moves the conversation forward.
Validation Rules Per Step
The table below lists every step ID, the exact validation logic fromapp.js, and the error message the user sees on failure.
| Step ID | Validation Rule | Error Message |
|---|---|---|
userName | value.length > 0 | Name cannot be blank. |
size | Must be small, medium, or large (case-insensitive) | Please enter small, medium, or large. |
toppings | value.length > 0 | Toppings cannot be blank. If you do not want any toppings, simply enter cheese. |
crustType | value.length > 0 | Crust type cannot be blank. |
quantity | Must match /^\d+$/ and be > 0 | Please enter a numeric value greater than 0. |
addAnother | Must be yes, y, no, or n (case-insensitive) | Please enter yes or no. |
method | Must be carry out, carryout, pickup, pick up, or delivery | Please enter carry out or delivery. |
paymentMethod | Must be cash, card, credit, debit, credit card, or debit card | Please enter cash or card. |
cardNumber | 13–19 digits after stripping spaces and hyphens — /^\d{13,19}$/ | Please enter a card number using 13 to 19 digits. |
cardExpiration | MM/YY format — /^(0[1-9]|1[0-2])\/\d{2}$/ | Please enter the expiration date as MM/YY. |
cardCvv | 3 or 4 digits — /^\d{3,4}$/ | Please enter a 3 or 4 digit security code. |
tip | Valid money value matching /^\$?\d+(\.\d{1,2})?$/ via isValidMoney() | Please enter a valid tip amount, like 3, 3.50, or 0. |
The handleSubmit() Validation Path
The entire validation gate lives in thehandleSubmit() function. Raw input is tested first; only after it passes is the value normalized, saved, and acted on.
#validationMessage element carries role="alert" in the HTML, so screen readers announce validation errors automatically without any extra JavaScript.
Normalization
Raw values that pass validation are immediately passed tonormalizeValue() before being stored. This coerces the many acceptable input variants into the single canonical form the rest of the app depends on.
- method —
carryout,pickup, andpick upall resolve to the canonical form"carry out". - addAnother —
"y"becomes"yes";"n"becomes"no". The branching logic inadvanceStep()only checks for"yes"and"no". - paymentMethod —
"credit","debit","credit card", and"debit card"all resolve to"card". Only"cash"stays"cash". - quantity — stored as a
Number, not a string, so arithmetic incalculateTotals()works without further conversion. - tip — the leading
$sign is stripped and the value is cast toNumber.
Error Display
The#validationMessage element is a <p> tag rendered below the submit button in the chat form. Its textContent is set to step.error when validation fails and cleared to an empty string when validation passes.