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
valibot/SourceSource
github
GitHubGitHub
DiscordDiscord
PreferencesPreferences
Created by eskimojo for Open Circle

Preferences

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