@zhead/validation
v1.1.0
Published
The `@zhead/schema` transformed to [Zod](https://github.com/colinhacks/zod].
Downloads
7
Readme
@zhead/validation
The @zhead/schema
transformed to [Zod](https://github.com/colinhacks/zod].
Provides safe parsing and validation of head schema.
Installation
npm install --save-dev @zhead/validation
# Using yarn
yarn add --dev @zhead/validation
API
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.ts
Example
If you'd like to parse or validate the full head schema you can do the following
import { headSchema } from "@zhead/validation"
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,
// }