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
effect/SourceSource
Code styleCode style
Normal styleNormal style
System themeSystem theme
Light themeLight theme
Dark themeDark theme
github
GitHubGitHub
DiscordDiscord
schemas/libraries/effect/download.ts
Copy to clipboardCopy to clipboard
import * as Schema from "effect/Schema"; import type { ProductData } from "#src"; const Image = Schema.Struct({ id: Schema.Number, created: Schema.instanceOf(Date), title: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(100)), type: Schema.Literal("jpg", "png"), size: Schema.Number, url: Schema.String.pipe(Schema.filter((value) => URL.canParse(value))), }); const Rating = Schema.Struct({ id: Schema.Number, stars: Schema.Number.pipe(Schema.greaterThanOrEqualTo(0), Schema.lessThanOrEqualTo(5)), title: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(100)), text: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(1000)), images: Schema.mutable(Schema.Array(Image)), }); const Product = Schema.Struct({ id: Schema.Number, created: Schema.instanceOf(Date), title: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(100)), brand: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(30)), description: Schema.String.pipe(Schema.minLength(1), Schema.maxLength(500)), price: Schema.Number.pipe(Schema.greaterThanOrEqualTo(1), Schema.lessThanOrEqualTo(10000)), discount: Schema.NullOr( Schema.Number.pipe(Schema.greaterThanOrEqualTo(1), Schema.lessThanOrEqualTo(100)), ), quantity: Schema.Number.pipe(Schema.greaterThanOrEqualTo(1), Schema.lessThanOrEqualTo(10)), tags: Schema.mutable(Schema.Array(Schema.String.pipe(Schema.minLength(1), Schema.maxLength(30)))), images: Schema.mutable(Schema.Array(Image)), ratings: Schema.mutable(Schema.Array(Rating)), }) satisfies Schema.Schema<ProductData>; Schema.decodeUnknownEither(Product)({});
Created by eskimojo for Open Circle