Schema validation
Validate the response, request body, path params and search params with Valibot. Types are inferred from your schemas.
Validation guide
Validate responses, bodies, path params and search params with Valibot. Retries, hooks, timeouts, SSE and download progress included.
npm install valifetch valibotimport valifetch from 'valifetch';
import * as v from 'valibot';
const UserSchema = v.object({
id: v.number(),
name: v.string(),
email: v.pipe(v.string(), v.email()),
});
const user = await valifetch.get('https://api.example.com/users/1', {
responseSchema: UserSchema,
});
// user: { id: number; name: string; email: string }If the server returns something that does not match the schema, the call rejects with a ValifetchError whose code is VALIDATION_ERROR.
A condensed, agent-oriented summary of the API is available at llms.txt.