Schema

Schema describes how untrusted boundary values become a model. If a field or constructor invariant fails, parsing returns SchemaErrors and does not return the model.

The declaration is reusable data. Input parsing executes it; inspection, JSON Schema, codecs, versioned contracts, and test-data generation interpret the same field names, value shapes, and constraints for their own jobs.

Reified.Schema: one declaration drives everything below A single field declaration fans downward into JSON codecs, parsers, contracts, docs and forms, and tests. One declaration drives all of it type Order = id : OrderId items : Item list total : Money JSON codecs Parsers Contracts Docs, forms Tests

Start here

Start with the Schema quickstart. It declares one record schema, parses structured input, reports every field failure with its path, and compiles the same declaration into a JSON codec.

After the quickstart, use these guides as needed:

  • Schema DSL — fields, constraints, constructors, and nested schemas.
  • Input Sources — name/value input, JSON-like data, CLI values, and configuration.
  • Construction Guarantees — what a schema proves and when a private type is needed.
  • Union Schemas — the recommended tagged-union format.
  • JSON Codecs — trusted serialization and deserialization from the same declaration.
  • Derived Schemas — generate schema declarations during the build.
  • Versioned Contracts — migrate frozen wire shapes into the current model.

Use the API reference for Schema when you need the complete constructor and interpreter catalogue rather than a guided workflow.

Packages

Package Use it for
Reified.Schema Model schemas, parsing, accumulated errors, inspection, and JSON Schema generation
Reified.Schema.Json Compiled JSON codecs
Reified.Schema.Contracts.Build Build-time derivation from F# records and .contract files

Install the core package and add the focused packages the application uses:

dotnet add package Reified.Schema
dotnet add package Reified.Schema.Json

JsonSchema is a module in Reified.Schema, not a separate package. Reified.Schema.Testing is an internal FsCheck adapter rather than an installable package; see Testing schema guarantees.

Schema controls values produced through Schema. A public F# record can still be constructed directly. Use refined fields, a private aggregate, or an opaque .fsi interface when other code must rely on the invariant without checking it again; Construction Guarantees compares those choices.