no asumir que offers es solo length===1

This commit is contained in:
Cat /dev/Nulo 2024-01-02 19:34:35 -03:00
parent db008c582f
commit 71e66cf437

View file

@ -32,7 +32,7 @@ const zProductLd = z.object({
name: z.string(), name: z.string(),
image: z.string(), image: z.string(),
offers: z.object({ offers: z.object({
offers: z.tuple([ offers: z.array(
z.object({ z.object({
"@type": z.literal("Offer"), "@type": z.literal("Offer"),
price: z.number(), price: z.number(),
@ -41,8 +41,8 @@ const zProductLd = z.object({
"http://schema.org/OutOfStock", "http://schema.org/OutOfStock",
"http://schema.org/InStock", "http://schema.org/InStock",
]), ]),
}), })
]), ),
}), }),
}); });
type ProductLd = z.infer<typeof zProductLd>; type ProductLd = z.infer<typeof zProductLd>;