requestValidation
constrequestValidation: (config?) =>Policy
Defined in: src/policies/transform/request-validation.ts:81
Pluggable request body validation policy.
Validates the request body using a user-provided sync or async function. Requests with content types not in the configured list pass through without validation.
Parameters
Section titled “Parameters”config?
Section titled “config?”Returns
Section titled “Returns”Example
Section titled “Example”import { requestValidation } from "@homegrower-club/stoma";
// Simple boolean validatorrequestValidation({ validate: (body) => body != null && typeof body === "object",});
// Detailed validation with error messagesrequestValidation({ validate: (body) => { const errors: string[] = []; if (!body || typeof body !== "object") errors.push("Body must be an object"); return { valid: errors.length === 0, errors }; },});