mirror of
https://github.com/ckaczor/Blog.git
synced 2026-01-14 09:59:13 -05:00
16 lines
317 B
JavaScript
16 lines
317 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);
|
|
}
|
|
}
|