3.1 KiB
3.1 KiB
A2UI Protocol Message Validation Logic
This document outlines the validation rules implemented in the validateSchema function. The purpose of this validator is to check for constraints that are not easily expressed in the JSON schema itself, such as conditional requirements and reference integrity.
An A2UI message is a JSON object that can have a surfaceId and one of the following properties, defining the message type: beginRendering, surfaceUpdate, dataModelUpdate, or deleteSurface.
Common Properties
surfaceId: An optional string that identifies the UI surface the message applies to.
BeginRendering Message Rules
- Required: Must have a
rootproperty, which is the ID of the root component to render.
SurfaceUpdate Message Rules
1. Component ID Integrity
- Uniqueness: All component
ids within thecomponentsarray must be unique. - Reference Validity: Any property that references a component ID (e.g.,
child,children,entryPointChild,contentChild) must point to an ID that actually exists in thecomponentsarray.
2. Component-Specific Property Rules
For each component in the components array, the following rules apply:
-
General:
- A component must have an
idand acomponentPropertiesobject. - The
componentPropertiesobject must contain exactly one key, which defines the component's type (e.g., "Heading", "Text").
- A component must have an
-
Heading:
- Required: Must have a
textproperty.
- Required: Must have a
-
Text:
- Required: Must have a
textproperty.
- Required: Must have a
-
Image:
- Required: Must have a
urlproperty.
- Required: Must have a
-
Video:
- Required: Must have a
urlproperty.
- Required: Must have a
-
AudioPlayer:
- Required: Must have a
urlproperty.
- Required: Must have a
-
TextField:
- Required: Must have a
labelproperty.
- Required: Must have a
-
DateTimeInput:
- Required: Must have a
valueproperty.
- Required: Must have a
-
MultipleChoice:
- Required: Must have a
selectionsproperty.
- Required: Must have a
-
Slider:
- Required: Must have a
valueproperty.
- Required: Must have a
-
Container Components (
Row,Column,List):- Required: Must have a
childrenproperty. - The
childrenobject must contain eitherexplicitListortemplate, but not both.
- Required: Must have a
-
Card:
- Required: Must have a
childproperty.
- Required: Must have a
-
Tabs:
- Required: Must have a
tabItemsproperty, which must be an array. - Each item in
tabItemsmust have atitleand achild.
- Required: Must have a
-
Modal:
- Required: Must have both
entryPointChildandcontentChildproperties.
- Required: Must have both
-
Button:
- Required: Must have
labelandactionproperties.
- Required: Must have
-
CheckBox:
- Required: Must have
labelandvalueproperties.
- Required: Must have
-
Divider:
- No required properties.
DataModelUpdate Message Rules
- Required: A
DataModelUpdatemessage must have acontentsproperty. - The
pathproperty is optional. - If
pathis not present, thecontentsobject will replace the entire data model. - If
pathis present, thecontentswill be set at that location in the data model. - No other properties besides
pathandcontentsare allowed.
DeleteSurface Message Rules
- Required: Must have a
deleteproperty set totrue. - No other properties are allowed.