The data to typeguard
True if the data is a SynthetikaProduct, false otherwise
const product = { id: 1, name: "Product 1", url: "https://example.com" };
if (isSynthetikaProduct(product)) {
console.log(product.name);
}
export function isSynthetikaProduct(data: unknown): data is SynthetikaProduct {
const check = v.safeParse(synthetikaProductResponseSchema, data);
if (!check.success) {
console.warn('isSynthetikaProduct: data is not a SynthetikaProduct', {
data,
check,
issues: check.issues,
});
}
return check.success;
}
This can be used to typeguard a SynthetikaProduct