v3: valibot instead of zod via adapter?
Hello,
It would be amazing to have the option of defining a custom validator instead of zod only – seems a very opionated assumption that everyone is using zod. We have migrated to valibot as (purely subjective) we deem it better, more lightweight and flexible.
Validators are purely matter of taste, so please consider making the schema property of data collections more generic, perhaps accept an object that can be generated from different sources or introduce an adapter that transforms to the necessary format?
Thank you for considering 🌈
Thanks for raising the concern.
Also, changing the validator library is not planned yet, but we are checking for ways to improve the validation in Nuxt Content. We might leverage https://standardschema.dev/ for generic validation, which unlocks the possibility of using different validation libraries.
But still Nuxt Content uses schema for other purposes, like generating database structure and this might be one of the blockers for supporting different libraries.
Thanks for the reply @farnabaz. Yes, https://standardschema.dev/ sounds like an ideal solution to allow different validators.
We already have an extensive set of complex Typescript types and maintaining a duplicate set of those via zod would be quite the headache.
As a workaround I am casting the query result to a certain type, I suppose that’s the easiest fix for that for now?
const queryPath = `/foo/bar`
// Can be either .json or .md
const { data } = await useAsyncData(queryPath, () => queryCollection("foo").path(queryPath).all())
// Filter .json files
const json = (data.value?.find((c) => c.extension === "json")?.body || {}) as FooType
ah. i want to use valibot with nuxt cotnent v3 but then found this issue by searching. and now i guess i;ve to mvoe ot zod for entire proejct. it;s just a start.