Deprecated Schema as Function
With version 0.9.0
, Content Collections now uses Standard Schema for the schema
property. This change allows you to utilize any Standard Schema compatible library, such as Zod or Valibot, to define the schema.
Starting with this version, using a function as a schema is deprecated. The function-based schema will continue to work for now, but it will be removed in a future version. To adopt the new schema, you must install your chosen library and update the schema definition in your configuration.
Let's examine the following example:
The old, deprecated way of defining the schema:
If we want to continue using Zod to define the schema, we first need to install the library:
Then, import Zod and use it directly to define the schema:
And that's it! You have successfully migrated to the new schema format.
Suppressing Deprecation Warning
If you are not ready to migrate yet, you can suppress the deprecation warning by setting the suppressDeprecationWarnings
option in your configuration: