Stone.js API
    Preparing search index...

    Route middleware: validates what a route declared, before its handler runs.

    A route says what it accepts, once, where the route is defined:

    @Post('/users', { validation: { body: CreateUserSchema } })
    

    A single schema means the body, which is what almost every route means; a map validates several sources at once ({ body, query, params }).

    This middleware reads that from the matched route and validates it. On success each parsed source is published in the event's metadata under a predictable name, so a handler reads event.get<CreateUser>('validatedBody') with no helper and no import. That matters more than it looks: a schema coerces and strips, and re-reading the raw value is how an application validates one thing and uses another. On failure it throws a ValidationError carrying every issue at once.

    The route stays the single description of itself, which is what lets @stone-js/openapi publish the request schema without being told a second time.

    Index
    • Validate the matched route's declared input, then continue.

      Parameters

      • event: IncomingEvent

        The incoming event.

      • next: NextMiddleware<IncomingEvent, OutgoingResponse>

        The next middleware.

      Returns Promise<OutgoingResponse>

      The response.