Skip to main content
Run these commands from the matching source checkout. Paths are relative to the repository root.

Validate a data contract

Source: crates/rydantic/examples/data_contract.rs
Normalizes a signup, prints four field errors for a second input and generates an input schema. No optional feature flags are needed. Follow the first-model tutorial to build it in a standalone project.

Inspect a model and its schema

Source: crates/rydantic/examples/user.rs
Prints a normalized user, structured errors and a schema report including local runtime rules. See validation and JSON Schema.

Dispatch a tagged tool call

Source: crates/rydantic/examples/tool_call.rs
The default command searches a local text corpus; ping returns {"results":["pong"]}. The last command prints the input schema. Invalid arguments produce structured errors and exit status 2.

Borrow from input JSON

Source: crates/rydantic/examples/borrowed.rs
Checks borrowed strings, flattened fields and extra keys. Escaped strings use owned storage where decoding requires it. See borrowed models for lifetime requirements.

Process arrays and NDJSON

Source: crates/rydantic/examples/streaming.rs
Visits a JSON array containing one invalid row, then processes newline-delimited JSON containing a malformed record. Prints row results and errors as it goes. This example parses input records; the AI streaming tutorial consumes model output.

Await a custom validator

Source: crates/rydantic/examples/asynchronous.rs
Accepts Alice and rejects the reserved name taken through an async field check. The simulated availability check is local. Read asynchronous validation to connect an application check.

Parse dates and exact decimals

Source: crates/rydantic/examples/dates_decimal.rs
Normalizes a timestamp and serializes an exact decimal string. Both optional features are required. See dates and decimals.

Generate a native Cap’n Proto codec

Source: crates/rydantic/examples/auto_capnp.rs Install the official capnp compiler and make it available on PATH, then run:
Derives bindings from model definitions, round-trips ordinary and packed messages, and prints the generated .capnp schema. See native Cap’n Proto for compiler setup and schema evolution.