Skip to content

Support Standard Schema (standardschema.dev) #129

Description

@kauandotnet

Summary

Standard Schema is a community spec created by the authors of Zod, Valibot, and ArkType. It defines a minimal common interface that validation libraries expose, so ecosystem tooling (AI/agent frameworks, form libraries, server frameworks, routers) can accept any compliant schema library without shipping vendor-specific adapters.

It would be great if Ack supported Standard Schema, positioning it as the Dart-side implementation of the spec. Ack is already the "Zod of Dart", and Zod, Valibot, and ArkType all implement Standard Schema — this would complete the story for cross-ecosystem tooling.

What the spec defines

A compliant schema exposes a ~standard property containing:

  • version — spec version (currently 1)
  • vendor — the library name (e.g. "ack")
  • validate — a function that takes an unknown value and returns either { value } on success or { issues } on failure, where each issue has a message and an optional path
  • types — inferred input/output types (TypeScript-specific; in Dart this maps naturally to generics)

There is also a companion spec, Standard JSON Schema, which defines a standard toJsonSchema() conversion. Ack already has JSON Schema export, so this half is arguably most of the way there already.

Why this fits Ack

  • LLM tooling focus: Ack's stated focus is structured data for LLM tools. Agent/AI frameworks are exactly the kind of consumers Standard Schema was designed for — they want to accept "any schema" for tool definitions and structured outputs without coupling to one library.
  • Ecosystem interop: a shared Dart interface would let form libraries, server frameworks, and codegen tools in the Dart/Flutter ecosystem consume Ack (or any future Dart validator) generically.
  • Precedent: on the TypeScript side, adoption by the big three validators made the spec the de facto integration point (tRPC, TanStack Form, Hono, etc. all consume it). Dart could follow the same path.

Proposal

Since the spec is TypeScript-native, "supporting" it in Dart means implementing an equivalent contract rather than the literal TS interface:

  1. Define a StandardSchemaV1<Input, Output> abstract interface in Dart mirroring the spec — vendor, version, and validate() returning a success/failure result with spec-shaped issues (message + path segments). This could live in a tiny standalone package (e.g. standard_schema) so other Dart validators can implement it too, with Ack as the reference implementation.
  2. Have AckSchema implement it — mapping safeParse() to validate() and Ack's error type to the spec's issues shape.
  3. For the Standard JSON Schema half, expose Ack's existing JSON Schema export through the spec's toJsonSchema() shape.

Happy to discuss scope — even just the interface + AckSchema conformance (steps 1–2) would unblock generic tooling.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions