Skip to navigation Skip to main content
These docs are for an upcoming version of Build Awesome — take extra care before linking here as URLs may change! Look to this page in the latest stable docs instead (or the full release history).

Validate Data Added in v3.0.0

Use the special eleventyDataSchema data property to validate data in your Data Cascade. You can set this anywhere in your Data Cascade (front matter, directory data file, global data, etc).

You can use any schema or validation library to achieve this. In this example, we’re using zod.

Example: Checking that draft is boolean

In the following example, each content template with an eleventyDataSchema callback (in this example, any templates in the blog folder) is checked to make sure the value of any draft assignments must be boolean or undefined. If not, we throw an error.

blog/blog.11tydata.js
import { z } from "zod";

export default {
	eleventyDataSchema: function(data) {
		let result = z.object({
			draft: z.optional(z.boolean())
		}).safeParse(data);

		if(result.error) {
			throw new Error(z.prettifyError(result.error));
		}
	}
};

Other pages in Using Data


Updated June 30, 2026
This page on 11ty