Validate a block (no write)
validate_blockValidate block payloads against authoring rules without saving, returning errors and warnings for HTML, JS, CSS to prevent runtime issues.
Instructions
Run the same authoring rules as create_block/update_block against a block payload WITHOUT writing it. Use it to iterate on HTML/JS/CSS until it's clean — it flags the footguns that only surface in a live browser (literal $ String.replace mangling, {{ }} interpolation, data polling, unscoped CSS, full docs, unsafe JS). Returns { valid, errors, warnings }. Pass against_block_id to preview GRANDFATHERING: errors the stored block already has are reported as pre_existing (update_block flags them as warnings instead of blocking).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| css | No | CSS section. | |
| data | No | HTML/JS section (the block `data`). | |
| name | No | Block name (optional for validation). | |
| css_file | No | Path to a file holding the block's CSS; the server reads it into `css`. Same byte-exact guarantee and same root containment as html_file. Mutually exclusive with `css`. | |
| html_file | No | Path to a file holding the block's HTML+JS; the server reads it into json_data.html. PREFER THIS over inlining large content: the bytes are read off disk byte-exact, so nothing is retyped and characters like em dashes or box-drawing cannot silently normalize. Mutually exclusive with json_data.html. Must resolve under the CWD, the VC dir, or a PORTAL_FILE_ROOTS entry. | |
| json_data | No | Widget/extra config. | |
| ui_queries | No | Query/datasource binding (this is how a block gets data — the portal has no `data` field). Array of { enabled, page_size, query_id, filter_strategy }, e.g. [{ "enabled": true, "page_size": 50, "query_id": "<query-uuid>", "filter_strategy": { "type": "blacklist", "value": [] } }]. The query_id must reference a saved query that already has a datasource attached. On update_block, the existing ui_queries is preserved automatically unless you pass a new value. | |
| against_block_id | No | Existing block UUID to compare against — splits errors into new vs pre-existing (grandfathered on update_block). |