LogoLogo

Schema Benchmarks

    • home
      Home

    • download_2
      Download

    • timer
      Initialization
    • check_circle
      Validation
    • output_circle
      Parsing
    • swap_horiz
      Codec
    • schema
      Standard Schema
    • format_quote
      String

    • error
      Stack

  • JSON Schema

    • data_object
      Schema to JSON
    • code
      JSON to Schema
    • verified
      Compliance

    • deployed_code
      Libraries

    • article
      Blog
Expand sidebarExpand sidebar
zod/mini/SourceSource
github
GitHubGitHub
DiscordDiscord
PreferencesPreferences
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures
schemas/libraries/zod/mini/download/index.ts
Copy to clipboardCopy to clipboard
schemas/libraries/zod/mini/download/index.ts
Copy to clipboardCopy to clipboard
schemas/libraries/zod/mini/download/index.ts
Copy to clipboardCopy to clipboard
import * as z from "zod/mini"; import type { ProductData } from "#src"; const imageSchema = z.object({ id: z.number(), created: z.date(), title: z .string() .check( z.minLength(1), z.maxLength(100), ), type: z.enum(["jpg", "png"]), size: z.number(), url: z.url(), }); const ratingSchema = z.object({ id: z.number(), stars: z .number() .check(z.minimum(1), z.maximum(5)), title: z .string() .check( z.minLength(1), z.maxLength(100), ), text: z .string() .check( z.minLength(1), z.maxLength(1000), ), images: z.array(imageSchema), }); const productSchema = z.toZod<ProductData>()( z.object({ id: z.number(), created: z.date(), title: z .string() .check( z.minLength(1), z.maxLength(100), ), brand: z .string() .check( z.minLength(1), z.maxLength(30), ), description: z .string() .check( z.minLength(1), z.maxLength(500), ), price: z .number() .check( z.minimum(1), z.maximum(10000), ), discount: z.nullable( z .number() .check( z.minimum(1), z.maximum(100), ), ), quantity: z .number() .check( z.minimum(0), z.maximum(10), ), tags: z.array( z .string() .check( z.minLength(1), z.maxLength(30), ), ), images: z.array(imageSchema), ratings: z.array(ratingSchema), }), ); productSchema.parse({});
import * as z from "zod/mini"; import type { ProductData } from "#src"; const imageSchema = z.object({ id: z.number(), created: z.date(), title: z.string().check(z.minLength(1), z.maxLength(100)), type: z.enum(["jpg", "png"]), size: z.number(), url: z.url(), }); const ratingSchema = z.object({ id: z.number(), stars: z.number().check(z.minimum(1), z.maximum(5)), title: z.string().check(z.minLength(1), z.maxLength(100)), text: z.string().check(z.minLength(1), z.maxLength(1000)), images: z.array(imageSchema), }); const productSchema = z.toZod<ProductData>()( z.object({ id: z.number(), created: z.date(), title: z .string() .check(z.minLength(1), z.maxLength(100)), brand: z .string() .check(z.minLength(1), z.maxLength(30)), description: z .string() .check(z.minLength(1), z.maxLength(500)), price: z.number().check(z.minimum(1), z.maximum(10000)), discount: z.nullable( z.number().check(z.minimum(1), z.maximum(100)), ), quantity: z.number().check(z.minimum(0), z.maximum(10)), tags: z.array( z.string().check(z.minLength(1), z.maxLength(30)), ), images: z.array(imageSchema), ratings: z.array(ratingSchema), }), ); productSchema.parse({});
import * as z from "zod/mini"; import type { ProductData } from "#src"; const imageSchema = z.object({ id: z.number(), created: z.date(), title: z.string().check(z.minLength(1), z.maxLength(100)), type: z.enum(["jpg", "png"]), size: z.number(), url: z.url(), }); const ratingSchema = z.object({ id: z.number(), stars: z.number().check(z.minimum(1), z.maximum(5)), title: z.string().check(z.minLength(1), z.maxLength(100)), text: z.string().check(z.minLength(1), z.maxLength(1000)), images: z.array(imageSchema), }); const productSchema = z.toZod<ProductData>()( z.object({ id: z.number(), created: z.date(), title: z.string().check(z.minLength(1), z.maxLength(100)), brand: z.string().check(z.minLength(1), z.maxLength(30)), description: z.string().check(z.minLength(1), z.maxLength(500)), price: z.number().check(z.minimum(1), z.maximum(10000)), discount: z.nullable(z.number().check(z.minimum(1), z.maximum(100))), quantity: z.number().check(z.minimum(0), z.maximum(10)), tags: z.array(z.string().check(z.minLength(1), z.maxLength(30))), images: z.array(imageSchema), ratings: z.array(ratingSchema), }), ); productSchema.parse({});