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
Expand sidebarExpand sidebar
sury/SourceSource
github
GitHubGitHub
DiscordDiscord
PreferencesPreferences
schemas/libraries/sury/download.ts
Copy to clipboardCopy to clipboard
import * as S from "sury"; import type { ProductData } from "#src"; const imageSchema = S.schema({ id: S.number, created: S.date, title: S.min(S.max(S.string, 100), 1), type: S.union(["jpg", "png"]), size: S.number, url: S.url, }); const ratingSchema = S.schema({ id: S.number, stars: S.min(S.max(S.number, 5), 0), title: S.min(S.max(S.string, 100), 1), text: S.min(S.max(S.string, 1000), 1), images: S.array(imageSchema), }); const productSchema = S.schema({ id: S.number, created: S.date, title: S.min(S.max(S.string, 100), 1), brand: S.min(S.max(S.string, 30), 1), description: S.min(S.max(S.string, 500), 1), price: S.min(S.max(S.number, 10000), 1), discount: S.union([S.min(S.max(S.number, 100), 1), null]), quantity: S.min(S.max(S.number, 10), 0), tags: S.array(S.min(S.max(S.string, 30), 1)), images: S.array(imageSchema), ratings: S.array(ratingSchema), }) satisfies S.Schema<ProductData>; S.parser(productSchema)({});
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser