Hi, first of all, thanks for this project – I'm loving being able to use my Airtable data in Astro.
The error I'm getting is in the airtableTypeToZodType function when using multipleLookupValues and formula fields:
InvalidContentEntryDataError: componentExamples → rec009nfVAzhubwTP data does not match collection schema.
Design system published.0: Expected type `"string"`, received "boolean"
Component published.0: Expected type `"string"`, received "boolean"
Published: Expected type `"string"`, received "number"
I believe this is because the code incorrectly assumes the result of multipleLookupValues is always an array of strings, and the result of formula is always a string.
Looking at the fields that are erroring, the result type is not a string:
Adding a check for options.result.type then setting the type based upon that fixes the error.
I've added this logic to the top of the airtableTypeToZodType function which fixes my individual use case. However, there's probably further work required to check all the other field types which could potentially contain non-string values.
if (type === "multipleLookupValues" && options?.result?.type) {
const resultType = options.result.type;
if (resultType === "checkbox") {
return z.array(z.boolean());
}
if (resultType === "number") {
return z.array(z.number());
}
if (resultType === "string") {
return z.array(z.string());
}
}
if (options?.result?.type) {
const resultType = options.result.type;
if (resultType === "checkbox") {
return z.boolean();
}
if (resultType === "number") {
return z.number();
}
if (resultType === "string") {
return z.string();
}
}
I'll try to put together a PR once I have time to test further.
Hi, first of all, thanks for this project – I'm loving being able to use my Airtable data in Astro.
The error I'm getting is in the
airtableTypeToZodType
function when usingmultipleLookupValues
andformula
fields:I believe this is because the code incorrectly assumes the result of
multipleLookupValues
is always an array of strings, and the result offormula
is always a string.Looking at the fields that are erroring, the result type is not a string:
Adding a check for
options.result.type
then setting the type based upon that fixes the error.I've added this logic to the top of the
airtableTypeToZodType
function which fixes my individual use case. However, there's probably further work required to check all the other field types which could potentially contain non-string values.I'll try to put together a PR once I have time to test further.