Bsft.Schema 2.3.0

dotnet add package Bsft.Schema --version 2.3.0
                    
NuGet\Install-Package Bsft.Schema -Version 2.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bsft.Schema" Version="2.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bsft.Schema" Version="2.3.0" />
                    
Directory.Packages.props
<PackageReference Include="Bsft.Schema" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bsft.Schema --version 2.3.0
                    
#r "nuget: Bsft.Schema, 2.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bsft.Schema@2.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bsft.Schema&version=2.3.0
                    
Install as a Cake Addin
#tool nuget:?package=Bsft.Schema&version=2.3.0
                    
Install as a Cake Tool

Bsft.Schema

A bounded subset of JSON Schema for documents a party the platform does not trust submitted: an application manifest's config schema, a webhook payload contract, a settings blob whose shape is not known at compile time. Reads a schema, refuses everything outside the subset by name, and checks a document against it with refusals a person can act on.

Install

dotnet add package Bsft.Schema

No third-party schema library and no framework dependency: the whole package is the subset below.

Register

services.AddBsftSchema();

or, to move the bounds into configuration:

services.AddBsftSchema(builder.Configuration);

Registers ISchemaReader and ISchemaValidator as singletons. Both hold no state between calls.

The subset

type: "object" at the root. Six types — string, integer, number, boolean, array, object — and per type: enum and default anywhere; format, pattern, minLength and maxLength on a string; minimum and maximum on a number; items, minItems and maxItems on an array; properties, required and additionalProperties: false on an object. $schema, title and description are carried as annotations. format is one of email, uri, date, date-time, uuid, or the two presentational values textarea and markdown, which constrain nothing.

That is the whole of it. There is no $ref, no allOf/anyOf/oneOf/not, no union type, no conditional schema and nothing else that can recurse without a bound.

Three decisions worth stating plainly, because each of them refuses documents a general-purpose validator would accept:

  • An unknown keyword is refused, not ignored. A schema writing maxLenght declares a bound the platform then does not enforce, on an install screen that says the field is validated. The developer finds out at submission, where a typo is cheap.
  • additionalProperties may only be false. An object with room in it for anything cannot be read back by anything downstream, and in a store it is where a tenant's own data ends up in a document the application's developer can read.
  • A pattern is compiled with backtracking off. That removes the catastrophic case outright rather than budgeting for it. The cost is that backreferences and lookaround are refused, which is the intended trade for an expression that arrived with the application.

Configure

BsftSchemaOptions.SectionName is "Bsft:Schema".

Option Default Effect
BsftSchemaOptions.MaxDepth 8 How deeply a schema or a document may nest.
BsftSchemaOptions.MaxProperties 100 How many properties one object may declare or carry.
BsftSchemaOptions.MaxSchemaNodes 500 How many nodes one schema may contain in total.
BsftSchemaOptions.MaxArrayItems 1000 How many items one array in a document may carry, above whatever the schema's own maxItems says.
BsftSchemaOptions.PatternTimeout 100 ms How long one pattern match may run.

Validation: every bound must be greater than zero. A zero is not a permissive setting but an absent one, and the ceiling exists because both documents are untrusted input.

Refusals

A SchemaViolation carries a JSON Pointer (/smtp/port), a code from SchemaCodes, and a sentence. All three, because a refusal is shown on an install screen rather than written to a log: the pointer is what makes it actionable in a document with forty fields, the code is what a caller branches on, and the sentence is the only part a person reads.

The codes split in two on purpose. SCHEMA_* is a defect in a document a developer submitted and belongs in a review queue; VALUE_* is a tenant's configuration not matching a schema that is itself fine, and belongs on the install screen. The two are shown to different people.

Extend

ISchemaReader and ISchemaValidator are the seams, registered with TryAdd. A host that has a schema language of its own registers its own reader; the validator then works against whatever SchemaNode that reader produced. SchemaNode is the boundary between the two, and reaching a validator means the subset and the bounds were already checked.

Documentation

Topic page: docs/schema.md. Conventions: docs/package-conventions.md.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.0 62 11/27/2026
2.2.0.1 115 10/31/2026
2.2.0 303 10/23/2026
2.1.0 126 9/28/2026