14 lines
308 B
JavaScript
14 lines
308 B
JavaScript
import { z } from "zod";
|
|
import { fromZodError } from 'zod-validation-error';
|
|
|
|
export default function(data) {
|
|
// Draft content, validate `draft` front matter
|
|
let result = z.object({
|
|
draft: z.boolean().or(z.undefined()),
|
|
}).safeParse(data);
|
|
|
|
if(result.error) {
|
|
throw fromZodError(result.error);
|
|
}
|
|
}
|