The response data to validate
Type predicate indicating if the data is a valid AmbeedProductListResponse
const response = await fetch("https://www.ambeed.com/api/search");
const data = await response.json();
if (isAmbeedProductListResponse(data)) {
console.log("Valid response, language:", data.lang);
console.log("Response code:", data.code);
}
export function isAmbeedProductListResponse(data: unknown): data is AmbeedProductListResponse {
return ambeedProductListResponseSchema.safeParse(data).success;
}
Type guard to validate if a response matches the Ambeed product list API response structure. Checks for the presence and correct types of source, code, lang, value, and time fields.