Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
# JSON Schema suites run separately below.
test/json_schema_*) continue ;;
# These suites read local files or run a Dart subprocess.
test/naming_conventions_test.dart|\
test/runtime_dependencies_test.dart|\
test/schemas/local_date_timezone_test.dart|\
test/schemas/object_presence_characterization_test.dart|\
Expand Down
19 changes: 17 additions & 2 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ explicit null triggers the default. Generated field wrappers continue to use
the field declaration's presence policy.

Refines: [field presence and unknown keys](#field-presence-and-unknown-keys).
Contract: [default values](docs/core-concepts/configuration.mdx#default-values).
Contract: [default values](docs/core-concepts/schemas.mdx#defaults).

## Stable rule annotations

Expand Down Expand Up @@ -73,7 +73,7 @@ namespace remains as deprecated redirecting constructors in 2.0.0-beta.3 and
is removed before Ack 2.0.0.

Replaces: [unified annotations](#unified-annotations-superseded).
Migration: [validation annotation table](docs/getting-started/migration-guide.mdx#validation-annotations).
Migration: [validation annotation table](docs/getting-started/migration-guide.mdx#removed-1x-and-beta-annotations).

## Single-part generation

Expand Down Expand Up @@ -123,6 +123,21 @@ objects become schema failures, so `safeParse` is not a blanket exception barrie
Contracts: [codecs](docs/core-concepts/codecs.mdx) and
[error handling](docs/core-concepts/error-handling.mdx).

## Naming of identifiers and fields

Date: 2026-12-02. Status: current. History: [#272](https://github.com/btwld/ack/pull/272).

Identifier values use lowercase snake_case: built-in constraint keys such as
`list_min_items` and diagnostic codes such as `unsupported_keyword`. Users log,
search, and compare these values across languages, as with other libraries'
error codes. Field names follow their host: Dart members and generated fields
use lowerCamelCase, and serialized error maps use camelCase fields such as
`constraintKey`, like the JSON Schema keywords Ack exports. Ack never renames
wire keys; generated models map them to Dart names. A new snake_case key costs
nothing, but renaming a key breaks users who match on it.

Contract: [naming test](packages/ack/test/naming_conventions_test.dart).

## Detached validating wire views

Date: 2026-10-27. Status: current. History: [#246](https://github.com/btwld/ack/pull/246).
Expand Down
34 changes: 12 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,6 @@
Ack validates data in Dart and Flutter. This branch documents **2.0.0-beta.3**;
see the [migration guide](docs/getting-started/migration-guide.mdx) 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:
Expand All @@ -33,19 +17,25 @@ Install the version documented on this branch:
dart pub add ack:^2.0.0-beta.3
```

```dart
```dart compile=body
import 'package:ack/ack.dart';

final userSchema = Ack.object({
'name': Ack.string().minLength(2),
'nickname': Ack.string().optional().nullable(),
'name': Ack.string().minLength(2).maxLength(50),
'age': Ack.integer().min(0).max(120),
'email': Ack.string().email().nullable(),
});

final result = userSchema.safeParse({
'name': 'Ada',
'age': 36,
'email': 'ada@example.com',
});

final result = userSchema.safeParse({'name': 'Ada'});
if (result.isOk) {
print(result.getOrThrow());
print('Welcome, ${result.getOrThrow()!['name']}');
} else {
print(result.getError());
print(result.getError()); // one path: message line per failure
}
```

Expand Down
4 changes: 0 additions & 4 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@
{
"group": "Adapter Authors",
"pages": [
{
"title": "Adapter Package Quickstart",
"href": "/guides/schema-converter-quickstart"
},
{
"title": "Creating Adapter Packages",
"href": "/guides/creating-schema-converter-packages"
Expand Down
Loading
Loading