brick.ts

Input and Output Validation

Validating actions with TypeBox schemas and error helpers.

llms.txt

This guide has been moved to Validation and Errors.

In Brick-TS, validation is powered directly by TypeBox schemas on actions (input and output) and the injected error helpers.

Please see the canonical guide: Validation and Errors.

Error responses

Input validation throws ValidationError with code VALIDATION_FAILED and status 400. Output validation uses the same code with status 500. Authorization failures use UNAUTHORIZED with status 401 when ctx.user is absent, and FORBIDDEN with status 403 when a signed-in user lacks access.

HTTP errors share { name, code, message, status, requestId, details?, errors? }. Unexpected errors return INTERNAL_SERVER_ERROR with a generic message. The server logs the original error and its cause with the request ID. Error helpers accept an optional third argument, such as error.CONFLICT("Already exists", { id }, { cause }); causes are never serialized.

On this page

Edit this page on GitHub

Last updated