$ cnpm install @zhead/zod
@zhead/zodThe @zhead/schema transformed to [Zod](https://github.com/colinhacks/zod].
Provides safe parsing and validation of head schema.
npm install --save-dev @zhead/zod
# Using yarn
yarn add --dev @zhead/zod
All exports are Zod based schemas and can be individually used to validate any part of the head schema.
headSchema - <head> schema. head.tsmetaSchema - <meta> schema. meta.tsmetaFlatSchema - flat <meta> schema. meta-flat.tslinkSchema - <link> schema. link.tsscriptSchema - <script> schema. script.tsstyleSchema - <style> schema. style.tsIf you'd like to parse or validate the full head schema you can do the following
import { headSchema } from "@zhead/zod"
headSchema.safeParse({
title: 'Test title',
meta: [
{ description: 'My Description' }
]
})
// {
// "error": [ZodError: [
// {
// "code": "custom",
// "message": "The attribute `content` must be included.",
// "path": [
// "meta",
// 0
// ]
// }
// ]],
// "success": false,
// }
Copyright 2013 - present © cnpmjs.org | Home |