Validation & structured output
Retries and validation together
Put validation() closest to the call (last .use()) so a transient network error retries via retries() first, and a schema failure retries separately via validation()'s own maxRetries.
← All recipes
import { Klaro, retries, validation } from "@klaroshield/sdk";
import { z } from "zod";
const klaro = new Klaro()
.use(retries({ max: 3 })) // handles 429/5xx
.use(validation({ schema: z.object({ ok: z.boolean() }) })); // handles bad JSONChecked against the shipped @klaroshield/sdk API. Full docs at klaro.services/klaroshield/docs.