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
Use eleventyDataSchema
in Data Cascade to validate data
#879
Comments
You could do this with the new #1206 access to Marginally related to #867!
|
Seems related to #3251 too |
This is shipping in 3.0.0-alpha.7 as the import { z } from "zod";
import { fromZodError } from 'zod-validation-error';
export default {
eleventyDataSchema: function(data) {
let result = z.object({
draft: z.boolean().or(z.undefined()),
}).safeParse(data);
if(result.error) {
throw fromZodError(result.error);
}
}
}; |
eleventyDataSchema
in Data Cascade to validate data
Shout out to https://github.com/uncenter/eleventy-plugin-validate by @uncenter |
Thanks! While we are on this topic... is there an easier way to narrow down the source of data? I'm using |
Looks like my little hack to access specifically front matter data got removed... 70df967#r141478000. It would be nice to be able to still, maybe with an unprefixed property? |
https://www.11ty.dev/docs/config/#linters are super cool, but I was hoping to have a linter for the raw input files so I could do a front-matter linter which would throw errors or otherwise report if a file was missing a "required" field in a file's front-matter.
Is something like that possible, or should I try and do that while defining a custom collection?
Or should it be something that I write separately using glob and grey-matter as a separate script?
The text was updated successfully, but these errors were encountered: