UI Error Messages β Authoring Guide
Anyone adding or editing a validation/error-message table under
docs/03-Integration/4-convenient-checkout-ui/13-Error-Messages/ β e.g. adding a new payment
method's field validations, or a new error scenario for an existing one.
This guide documents how validation and error-message tables are structured and rendered from
JSON data files, as implemented under 13-Error-Messages/. The folder holds the pages
(index.md, add-payment-method-screen.md, edit-payment-method-screen.md) at its top level and
the JSON data in Payment Mode/ and Wallet Mode/Payment Method/ subfolders (plus
card-telephonic-form-validation-data.json at the top level). Data covers ACH, Card, and
Card-Telephonic payment methods.
Two JSON Shapesβ
There are two distinct JSON shapes in use, covering two different kinds of validation content.
The pages import them by relative path (e.g. ./Wallet Mode/Payment Method/ach-validation-data.json), and both use a modes array to indicate
which page mode(s) β "add", "edit", etc. β each row applies to.
1. Field-level validation (*-validation-data.json)β
One row per form field, with the field's validation rules and the resulting error messages as
arrays. Example β ach-validation-data.json:
[
{
"fieldName": "Name on Account",
"modes": ["add", "edit"],
"validationRules": [
"This field is required.",
"Should contain only alphabets and special characters."
],
"errorMessages": [
"Name on account is required.",
"Name on account is invalid. Please make sure name field includes alphabet and special characters only."
]
},
{
"fieldName": "Routing Number",
"modes": ["add"],
"validationRules": [
"This field is required.",
"Must be 9 characters long.",
"Must only have numerical values."
],
"errorMessages": [
"Routing number is required.",
"Routing number is incomplete.",
"Enter a valid routing number."
]
}
]
Rendered as a 3-column table: Field Name | Validation Rules | Error Messages. See
ach-validation-data.json, card-validation-data.json, and card-telephonic-validation-data.json
for the other payment methods.
2. Form/scenario-level validation (*-form-validation-data.json)β
One row per error scenario (not per field) β a flatter shape with a single errorMessage,
used for form-wide or cross-field errors like a duplicate payment method. Example β
ach-form-validation-data.json:
[
{
"errorScenario": "Duplicate Payment Method",
"errorMessage": "This payment method already exists in your wallet.",
"modes": ["add", "edit"]
},
{
"errorScenario": "Invalid Routing Number",
"errorMessage": "The routing number you entered is invalid. Please check the number and try again.",
"modes": ["add", "edit"]
}
]
Rendered as a 2-column table: Error Scenario | Error Message. See ach-form-validation-data.json,
card-form-validation-data.json, and card-telephonic-form-validation-data.json.
Importing and Filteringβ
Import whichever JSON files the page needs at the top of the .md/.mdx file:
import achValidationData from './Wallet Mode/Payment Method/ach-validation-data.json';
import achFormValidationData from './Wallet Mode/Payment Method/ach-form-validation-data.json';
Filter before rendering so only the rows relevant to the current mode/column show up. The
simplest case filters on modes alone:
// Field-level table, add mode:
{achValidationData.filter(row => row.modes.includes('add')).map((row, index) => (
<tr key={index}>
<td>{row.fieldName}</td>
<td>
{row.validationRules.map((rule, i) => (
<React.Fragment key={i}>
{i + 1}. {rule}
<br />
</React.Fragment>
))}
</td>
<td>
{row.errorMessages.map((msg, i) => (
<React.Fragment key={i}>
{i + 1}. {msg}
<br />
</React.Fragment>
))}
</td>
</tr>
))}
// Form/scenario-level table:
{achFormValidationData.filter(row => row.modes.includes('add')).map((row, index) => (
<tr key={index}>
<td>{row.errorScenario}</td>
<td>{row.errorMessage}</td>
</tr>
))}
Real pages often chain extra conditions onto the modes filter β don't assume modes is the
only predicate you'll need. For example, card-validation-data.json excludes a row that isn't a
real field and one whose message is a placeholder:
{cardValidationData.filter(row =>
row.modes.includes('add') &&
row.fieldName !== 'Payment Element' &&
!row.errorMessages.includes('N/A')
).map(/* ... */)}
And some pages filter a form-level table by excluding a scenario that doesn't apply to that page, instead of filtering by mode:
{achFormValidationData.filter(row => row.errorScenario !== 'Duplicate Payment Method').map(/* ... */)}
Rendering Logicβ
- Tables use standard HTML
<table>,<thead>,<tbody>tags. - Rows are generated with
.map()over the (filtered) JSON array. - Array-valued cells (
validationRules,errorMessages) are numbered and line-broken with<React.Fragment>, so multiple rules/messages render as a numbered list without adding extra DOM nodes:{row.validationRules.map((rule, i) => (<React.Fragment key={i}>{i + 1}. {rule}<br /></React.Fragment>))} - The table is fully data-driven: editing the JSON file is enough to update the rendered table β
no changes needed in the
.mdfile itself, as long as the shape (and any extra filter conditions a given page relies on) stays the same.
Why This Approach?β
- Consistency: every validation/error table on the site uses the same two data shapes and the same rendering logic.
- Reusability: a payment method's JSON files can be imported by more than one page mode (e.g. both add and edit) without duplicating the table markup.
- Maintainability: updating the JSON file updates every table that imports it β no hunting for duplicated inline tables across pages.
Reference Implementationsβ
Paths are under docs/03-Integration/4-convenient-checkout-ui/13-Error-Messages/.
add-payment-method-screen.mdβ both JSON shapes, mode-based filtering, Payment Mode and Wallet Mode data, all three payment methodsedit-payment-method-screen.mdβ edit-mode filtering of Wallet Mode ACH and Card dataindex.mdβ the landing page for the section- JSON data:
Payment Mode/*.json,Wallet Mode/Payment Method/*.json, andcard-telephonic-form-validation-data.json
Related Documentationβ
- Error Messages β the rendered pages this guide describes
For further improvements, update this guide or contact the documentation maintainers.