You are viewing the docs for the newest version. You can view the docs for 0.5 here

Quick Start

After installing the package, you can begin to use the functions in your code:

import { z, parseDataAs } from "@sidebase/nuxt-parse"const parsedData = await parseDataAs({ test: "1" }, z.object({ test: z.number() )}))// -> throws! `"1"` is not a number, but a string!const parsedData = await parseDataAs({ test: 1 }, z.object({ test: z.number() )}))console.log(parsedData)// -> output: `{ test: 1 }`const parsedData = await parseDataAs({ test: "1" }, z.object({ test: z.string().transform(v => parseInt(v)) )}))console.log(parsedData)// -> output: `{ test: 1 }` (we used `.transform` to ensure that we get a number)

You can view some other examples here.