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

    • article
      Blog
Code styleCode style
Normal styleNormal style
System themeSystem theme
Light themeLight theme
Dark themeDark theme
Expand sidebarExpand sidebar
zod/mini/SourceSource
Code styleCode style
Normal styleNormal style
System themeSystem theme
Light themeLight theme
Dark themeDark theme
github
GitHubGitHub
DiscordDiscord
schemas/libraries/zod/mini/download.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(0), 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.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), }) satisfies z.ZodMiniType<ProductData>; productSchema.parse({});
Created by eskimojo for Open Circle