Compute and format
FunctionsThese functions are part of the Basic Catalog in Google's A2UI v1.0 protocol. This page shows how they behave so you can build with them. Unofficial, and not affiliated with Google.
| Function | Example arguments | Expected (SDK reference) | Observed | Result |
|---|---|---|---|---|
| {"value": "x"} | disabled=False (valid=True) | disabled=False | PASS |
{"value": ""} | disabled=True (valid=False) | disabled=True | PASS | |
Try your own arguments for | ||||
| {"value": "abc", "pattern": "^[a-z]+$"} | disabled=False (valid=True) | disabled=False | PASS |
{"value": "ABC", "pattern": "^[a-z]+$"} | disabled=True (valid=False) | disabled=True | PASS | |
Try your own arguments for | ||||
| {"value": "abcd", "min": 3, "max": 5} | disabled=False (valid=True) | disabled=False | PASS |
{"value": "ab", "min": 3} | disabled=True (valid=False) | disabled=True | PASS | |
Try your own arguments for | ||||
| {"value": 5, "min": 1, "max": 10} | disabled=False (valid=True) | disabled=False | PASS |
{"value": 11, "min": 1, "max": 10} | disabled=True (valid=False) | disabled=True | PASS | |
Try your own arguments for | ||||
| {"value": "a@b.co"} | disabled=False (valid=True) | disabled=False | PASS |
{"value": "nope"} | disabled=True (valid=False) | disabled=True | PASS | |
Try your own arguments for | ||||
| {"values": [true, true]} | disabled=False (valid=True) | disabled=False | PASS |
{"values": [true, false]} | disabled=True (valid=False) | disabled=True | PASS | |
Try your own arguments for | ||||
| {"values": [false, false]} | disabled=True (valid=False) | disabled=True | PASS |
{"values": [false, true]} | disabled=False (valid=True) | disabled=False | PASS | |
Try your own arguments for | ||||
| {"value": true} | disabled=True (valid=False) | disabled=True | PASS |
{"value": false} | disabled=False (valid=True) | disabled=False | PASS | |
Try your own arguments for | ||||
| Hi ${/name}, ${/age} with /name Ada, /age 36, then /name Bob | Hi Ada, 36 then Hi Bob, 36 | Hi Ada, 36 then Hi Bob, 36 | PASS |
formatString with model interpolation; update model, text follows | interpolation follows the model | | PASS | |
Try your own arguments for | ||||
| {"value": 1234567.891, "decimals": 2, "grouping": true} | 1,234,567.89 | 1,234,567.89 | PASS |
{"value": 1234567.891, "decimals": 0, "grouping": false} | 1234568 | 1234568 | PASS | |
formatNumber, formatCurrency, formatDate together on one value | formatNumber, formatCurrency, formatDate match the SDK reference | | PASS | |
Try your own arguments for | ||||
| {"value": 1234.5, "currency": "USD"} | $1,234.50 | $1,234.50 | PASS |
{"value": 1234.5, "currency": "EUR", "decimals": 0} | €1,234 | €1,235Expected and observed differ; see the note under the table. | DIFF | |
Try your own arguments for | ||||
| {"value": "2026-11-14T10:00:00Z", "format": "yyyy-MM-dd"} | 2026-11-14 | 2026-11-14 | PASS |
{"value": "2026-11-14T10:00:00Z", "format": "MMM d, yyyy"} | Nov 14, 2026 | Nov 14, 2026 | PASS | |
Try your own arguments for | ||||
| {"value": 1, "one": "item", "other": "items"} | item | item | PASS |
{"value": 2, "one": "item", "other": "items"} | items | items | PASS | |
{"value": 0, "zero": "none", "one": "item", "other": "items"} | none | none | PASS | |
pluralize one/other; model 1 -> 2 | one then other | | PASS | |
Try your own arguments for | ||||
DIFF in formatCurrency: for {"value": 1234.5, "currency": "EUR", "decimals": 0} the SDK reference gives €1,234 and the browser, through the renderer, gives €1,235. The cause is how an exact half is rounded: the Python library the SDK uses rounds half to even (1234.5 gives 1,234; 1235.5 gives 1,236), while the browser rounds half away from zero (1234.5 gives 1,235). The specification guide says to use the platform's native number formatting and does not name a rounding rule, so we do not call either one wrong.