-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Content collections] Documentation should maybe specify that the z.object
wrapper is needed?
#4306
Comments
Note that I suppose the schema actually does accept a few other things besides |
Thanks for the feedback! We clarify usage of Zod in a later section (Defining datatypes with Zod). We could maybe append "using Zod" to clarify what we're using to define a schema?
|
I think (again this is just me) the problem isn't so much about clarifying the use of Zod (which is fairly well documented), but the use of Zod objects. I set up several schemas using Basically I wish I had known beforehand that this isn't setup correctly, and why:
|
I'd expect arrays to be valid in data collections, so if they're not, it might be a bug. |
Honestly same, and if arrays could be supported in data collections that would indeed make my life a lot easier! but since you specified in issue 8163 (linked above) that they aren't, I figured there must be some reason π |
@Acccent I've created an example on the latest version, which seems to work fine: Stackblitz We could probably use an example somewhere on the page, to make it clear this is a supported use-case. |
Yeah in withastro/astro#8163 I was specifically solving a content collection schema issue and had not considered data collections. We should probably make the supported types for content and data collections different to support a wider range in data collections. |
Okay, it looks like it was fixed in the last few releases :) Sorry about the false alarm and thanks for checking it! |
π Subject area/topic
Content Collections guide β specifically, defining schemas.
π Page(s) affected (or suggested, for new content)
https://docs.astro.build/en/guides/content-collections/#defining-a-collection-schema
π Explain your issue
Following this change, collection schemas require a
z.object
wrapper; the examples in the docs have already been changed accordingly.Personally when reading the docs, it wasn't clear that the examples were demonstrating the required structure β I thought
z.object
was used as, well, an example.I would suggest something like this in the documentation for defining schemas (changes in italics):
The text was updated successfully, but these errors were encountered: