The data to verify (raw response from Synthetika)
True if the data is a SynthetikaSearchResponse, false otherwise
const response = await fetch("https://synthetikaeu.com/webapi/front/en_US/products/usd/search/sodium%20chloride");
if (isSynthetikaSearchResponse(response)) {
console.log(response.count);
}
export function isSynthetikaSearchResponse(data: unknown): data is SynthetikaSearchResponse {
const check = v.safeParse(synthetikaSearchResponseSchema, data);
if (!check.success) {
console.warn('isSynthetikaSearchResponse: data is not a SynthetikaSearchResponse', {
data,
check,
issues: check.issues,
});
}
return check.success;
}
This can be used to check if a SynthetikaSearchResponse is valid