Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sebamar88/bytekit/llms.txt
Use this file to discover all available pages before exploring further.
Powered by Mintlify
Auto-generate your docs
Runtime response validation for API responses
Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sebamar88/bytekit/llms.txt
Use this file to discover all available pages before exploring further.
import { ResponseValidator } from "bytekit";
// or
import { ResponseValidator } from "bytekit/response-validator";
const userSchema = {
type: "object",
required: ["id", "name", "email"],
properties: {
id: { type: "string" },
name: { type: "string" },
email: { type: "string" },
age: { type: "number" }
}
};
import { ApiClient } from "bytekit";
const api = new ApiClient({
baseUrl: "https://api.example.com"
});
const user = await api.get<User>("/users/123", {
validateResponse: userSchema
});
// Throws if response doesn't match schema
import { ResponseValidator } from "bytekit";
const validator = new ResponseValidator();
const data = { id: "123", name: "John", email: "john@example.com" };
if (validator.validate(data, userSchema)) {
console.log("Valid response");
} else {
console.error("Invalid response", validator.errors);
}