SERVER ECOSYSTEM

Validation Adapters

@rasenganjs/validators is the package behind Validation — Rasengan Server depends on it directly, so it's already installed as part of @rasenganjs/server.

Using It Directly with Futon

Rasengan Server wires this up for you automatically, but you can use it standalone with plain Futon too:

Standalone usage
import { z } from 'zod'; import { createValidationMiddleware, zodAdapter } from '@rasenganjs/validators'; const schemas = { body: z.object({ name: z.string() }) }; const validate = createValidationMiddleware(schemas, { adapter: zodAdapter }); app.post('/users', validate, handler);

SchemaAdapter — Bring Your Own Schema Library

Validation is adapter-based by design — zodAdapter is the only one shipped today, but any schema library can plug in by implementing SchemaAdapter:

interface SchemaAdapter<TSchema = any, TOutput = any> { parse<O = TOutput>( schema: TSchema, data: unknown ): { success: true; data: O } | { success: false; errors: ValidationError[] }; infer<T>(schema: T): unknown; // type-level only, no runtime effect }
A minimal custom adapter
import type { SchemaAdapter } from '@rasenganjs/validators'; const myAdapter: SchemaAdapter = { parse(schema, data) { const result = schema.safeParse(data); // whatever your library's API looks like if (result.success) return { success: true, data: result.data }; return { success: false, errors: result.errors.map(toValidationError) }; }, infer: (schema) => schema, }; app.configureValidation({ adapter: myAdapter });

ValidationError

interface ValidationError { path: (string | number)[]; // e.g. ["address", "city"] message: string; code?: string; // adapter-specific }

Exports at a Glance

ExportDescription
createValidationMiddleware(schemas, config)Factory for a runtime Middleware
zodAdapterThe built-in SchemaAdapter for Zod
SchemaAdapterInterface for implementing other schema libraries
SchemaDefinitionPer-route { body?, params?, query?, onError? } shape
InferBody / InferParams / InferQueryType-level extraction of a schema's inferred output
ValidationConfigGlobal { adapter, onError } shape (see app.configureValidation())
ValidationErrorSingle field error shape
defaultErrorHandlerBuilt-in 400 JSON error response
formatZodErrorConverts a Zod error into ValidationError[]

See Controllers & Routing and Validation for how this integrates with the Router and Controller.schemas.

Background Queues
Database (Drizzle)