|
13 | 13 | - [Testing Instructions](#testing-instructions) |
14 | 14 | - [Quick Start](#quick-start) |
15 | 15 | - [Development Commands](#development-commands) |
| 16 | +- [Scenario Validation API](#scenario-validation-api) |
16 | 17 | - [Current Status](#current-status) |
17 | 18 | - [Roadmap](#roadmap) |
18 | 19 | - [Features](#features-available-in-alpha-01x-02x) |
@@ -185,6 +186,35 @@ Choices are important elements that let players control game progression. You ca |
185 | 186 | - `npm run docs:build` - Build documentation |
186 | 187 | - `npm run docs:preview` - Preview built documentation |
187 | 188 |
|
| 189 | +## Scenario Validation API |
| 190 | +
|
| 191 | +webTaleKit provides a public API for validating scenario arrays and non-destructively sanitizing HTML-like string content. |
| 192 | +
|
| 193 | +- `validateScenarioObjects` returns validation results and a sanitized scenario |
| 194 | +- `formatValidationOutput` converts errors and warnings into display-friendly strings |
| 195 | +- `createScenarioValidationError` builds an `Error` from validation results |
| 196 | +- `assertScenarioValidation` throws when validation errors exist |
| 197 | +- `reportScenarioValidation` sends warnings and errors through the logger |
| 198 | +
|
| 199 | +These APIs are not automatically enforced by the engine at runtime. They are intended to be called explicitly by the user from scene import flows, editor integrations, custom build steps, or server-side tooling. |
| 200 | +
|
| 201 | +```ts |
| 202 | +import { |
| 203 | + assertScenarioValidation, |
| 204 | + reportScenarioValidation, |
| 205 | + validateScenarioObjects, |
| 206 | +} from './src/utils/validateScenario' |
| 207 | +
|
| 208 | +const result = validateScenarioObjects(scenarioObjects, commandList) |
| 209 | +
|
| 210 | +await reportScenarioValidation(result, 'Scene import') |
| 211 | +assertScenarioValidation(result, 'Scene import') |
| 212 | +
|
| 213 | +const safeScenario = result.sanitizedScenario |
| 214 | +``` |
| 215 | +
|
| 216 | +`sanitizedScenario` is returned without mutating the original input array. When `sanitized` is `true`, HTML-like text has been escaped. |
| 217 | +
|
188 | 218 | ## Current Status |
189 | 219 |
|
190 | 220 | webTaleKit is currently in alpha. |
|
0 commit comments