import type { Context, MiddlewareHandler, Env, ValidationTargets } from "hono"; import type { Infer, Struct, StructError } from "superstruct"; /** * A function constructs a Hono response from the given {@link StructError}. * * @param error The error that occurred while trying to validate a Superstruct schema. * @param context The Hono request context. * @returns A response, or a promise that resolves with a response. */ export type OnError = (error: StructError, context: Context) => globalThis.Response | Promise; /** * Constructs simple validator middleware for Hono to ensure incoming data matches * a given Superstruct schema. * * @param target The format for which this validator should apply (i.e. * `"json"` or `"form"`) * @param struct The Superstruct schema against which the request body * should be strictly validated. * @param onError An optional callback to handle the {@link StructError} if * the body could not be validated. This callback will not be called if * the request body passes the schema's validation. * @returns Hono middleware that ensures later steps can get valid data * from the request body. */ export declare const sValidator: , Target extends keyof ValidationTargets, E extends Env, Path extends string, V extends { in: { [K in Target]: Infer; }; out: { [K_1 in Target]: Infer; }; } = { in: { [K_2 in Target]: Infer; }; out: { [K_3 in Target]: Infer; }; }>(target: Target, struct: T, onError?: OnError | undefined) => MiddlewareHandler;