8000 GitHub - btwld/ack: A modern Dart schema library for structured data, with a focus on LLM tools in mind. · GitHub
[go: up one dir, main page]

Skip to content
btwldPublic

About

A modern Dart schema library for structured data, with a focus on LLM tools in mind.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

64 stars

Watchers

1 watching

Forks

Ack

CI pub package

Ack validates data in Dart and Flutter. This branch documents 2.0.0-beta.3; see the migration guide for 1.x changes.

Core concepts

  • Schemas define accepted boundary data and the Dart values it becomes.
  • Parsing validates input; safeParse returns a result. Codecs also encode runtime values back to the boundary.
  • Presence and null differ: optional permits omission, nullable permits null, and JsonMaybe preserves both states.
  • Generation is optional: @Schemable turns schemas into models or hand-written classes into schemas, using one .g.dart part.
  • Generated model constructors are unchecked; use parsing for untrusted input and JSON encoding for validated output.
  • Native schemas export Draft-7; imported 2020-12 resources retain their dialect unless explicitly lowered.
  • Adapters reuse schemas for Firebase AI, MCP inputs, and json_schema_builder; Ack still validates the data.

Start here

Install the version documented on this branch:

dart pub add ack:^2.0.0-beta.3
import 'package:ack/ack.dart';

final userSchema = Ack.object({
  'name': Ack.string().minLength(2),
  'nickname': Ack.string().optional().nullable(),
});

final result = userSchema.safeParse({'name': 'Ada'});
if (result.isOk) {
  print(result.getOrThrow());
} else {
  print(result.getError());
}

See installation for SDK requirements, model generation for @Schemable, and codecs for encoding and callback failure semantics.

Packages

Package Purpose
ack Runtime schemas, codecs, JSON Schema import/export, annotations
ack_generator Models from schemas and schemas from classes
ack_firebase_ai Firebase AI response JSON Schema maps
ack_json_schema_builder Bidirectional json_schema_builder bridge
ack_mcp_dart MCP input schemas and typed argument validation

Examples demonstrate the packages together.

Documentation and contributing

About

A modern Dart schema library for structured data, with a focus on LLM tools in mind.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

64 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

0