C# SDK

Local validation of INHERIT estate documents in .NET with embedded schemas. Record types, static API, and Level 2 referential integrity checking.

C# v6.0.01 min read
Package: OpenInherit.Sdk

Installation#

bash
dotnet add package OpenInherit.Sdk

Targets .NET 9.0. The JSON Schema validation library (JsonSchema.Net) is included as a dependency.

Quick start#

csharp
using OpenInherit.Sdk;

string json = File.ReadAllText("estate.json");
ValidationResult result = Validator.Validate(json);

if (result.Valid)
{
    Console.WriteLine($"Valid (Level {result.ConformanceLevel})");
}
else
{
    foreach (var error in result.Errors)
    {
        Console.WriteLine($"  {error.Path}: {error.Message}");
    }
}

API reference#

Validator.Validate(string jsonDocument)#

Validates an INHERIT document, auto-detecting estate or catalogue mode from the $schema property.

Validator.ValidateEstate(string jsonDocument)#

Validates a document as an estate document regardless of its $schema property.

Validator.ValidateCatalogue(string jsonDocument)#

Validates a document as a catalogue document regardless of its $schema property.

Validator.ValidateLevel2(string jsonDocument)#

Performs Level 2 validation: JSON Schema validation followed by UUID cross-reference checking.

Types#

csharp
public record ValidationResult(
    bool Valid,
    string SchemaMode,
    int ConformanceLevel,
    IReadOnlyList<ValidationError> Errors,
    string Disclaimer
);

public record ValidationError(string Path, string Message, int Level = 1);

public static class ConformanceLevel
{
    public const int Failed = 0;
    public const int Level1 = 1;
    public const int Level2 = 2;
}

Examples#

Level 2 validation#

csharp
var result = Validator.ValidateLevel2(json);

Console.WriteLine(result.ConformanceLevel switch
{
    ConformanceLevel.Level2 => "Fully conformant",
    ConformanceLevel.Level1 => "Schema valid, broken references",
    _ => "Schema validation failed"
});

ASP.NET minimal API#

csharp
app.MapPost("/validate", (HttpRequest request) =>
{
    using var reader = new StreamReader(request.Body);
    var json = reader.ReadToEndAsync().Result;
    return Validator.Validate(json);
});

Get in touch

Have a question about INHERIT, or interested in becoming a partner? We'd love to hear from you.

By submitting this form, you agree to our Privacy Policy. Your data is processed by Formspark (EU) and retained until your enquiry is resolved.

or email hello@openinherit.org