Purview.ZodSharp.SystemTextJson 2.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Purview.ZodSharp.SystemTextJson --version 2.3.0
                    
NuGet\Install-Package Purview.ZodSharp.SystemTextJson -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="Purview.ZodSharp.SystemTextJson" Version="2.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Purview.ZodSharp.SystemTextJson" Version="2.3.0" />
                    
Directory.Packages.props
<PackageReference Include="Purview.ZodSharp.SystemTextJson" />
                    
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 Purview.ZodSharp.SystemTextJson --version 2.3.0
                    
#r "nuget: Purview.ZodSharp.SystemTextJson, 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 Purview.ZodSharp.SystemTextJson@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=Purview.ZodSharp.SystemTextJson&version=2.3.0
                    
Install as a Cake Addin
#tool nuget:?package=Purview.ZodSharp.SystemTextJson&version=2.3.0
                    
Install as a Cake Tool

Purview.ZodSharp.SystemTextJson

NuGet version Release

System.Text.Json integration for Purview.ZodSharp NuGet version. Deserialize-and-validate JSON in a single pass, create validating JsonConverter<T> instances, and import JSON Schema definitions (Z.FromJsonSchema).

Installation

dotnet add package Purview.ZodSharp.SystemTextJson

Deserialize and validate

using ZodSharp;

var userSchema = Z.Object()
    .Field("name", Z.String().Min(3))
    .Field("age", Z.Number().Min(0).Int())
    .Build();

var json = """{ "name": "John", "age": 30 }""";

var result = userSchema.DeserializeAndValidate(json);
if (result.IsSuccess)
    Console.WriteLine($"Valid: {result.Value}");

Async stream overload:

await using var stream = File.OpenRead("user.json");
var result = await userSchema.DeserializeAndValidateAsync(stream);

Validating converter

var converter = userSchema.CreateValidatingConverter();
var options = new JsonSerializerOptions { Converters = { converter } };
var value = JsonSerializer.Deserialize<User>(json, options);

UTC DateTimeOffset contract

The default PreserveOffset schema is exact and needs no converter. When the generated JSON Schema uses DateTimeOffsetSerialization.Utc, add the matching converter so the serializer writes UTC and rejects a value without an explicit Z/zero offset (or with a non-zero offset) on read:

using ZodSharp.Json.Serialization.SystemTextJson;

var options = new JsonSerializerOptions
{
    Converters = { new UtcDateTimeOffsetConverter() },
};

PreserveOffsetDateTimeOffsetConverter is available to opt a type or property back out of a project-wide UTC converter. See JSON Schema Export.

Import from JSON Schema

using ZodSharp;
using ZodSharp.JsonSchema.SystemTextJson;

var schema = Z.FromJsonSchema(jsonSchemaString);
var result = schema.Validate(data);

This lets you share schemas defined in TypeScript/Zod with your .NET backend. (Export via Z.ToJsonSchema lives in the core package.)

Documentation

License

MIT — see the package metadata in Purview.ZodSharp.SystemTextJson on NuGet.

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 is compatible.  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.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Purview.ZodSharp.SystemTextJson:

Package Downloads
Purview.EventSourcing.Admin.API

ASP.NET Minimal API endpoints for Purview EventSourcing Admin Portal with OpenAPI documentation.

Purview.EventSourcing.Admin.Site

Ready-to-use Razor Pages admin dashboard for Purview EventSourcing Admin Portal. Provides web UI for aggregate search, event inspection, and point-in-time projection queries.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.4.1 66 10/23/2026
2.4.0 216 10/22/2026
2.3.0 51 10/22/2026
2.2.0 101 10/18/2026
2.1.0 88 10/16/2026
2.0.2 115 10/8/2026
2.0.1.1 97 10/7/2026
2.0.1 95 10/7/2026
2.0.0 102 9/29/2026
2.0.0-prerelease.28 81 9/28/2026
2.0.0-prerelease.27 72 9/27/2026
2.0.0-prerelease.26 74 9/27/2026
2.0.0-prerelease.25 72 9/27/2026
2.0.0-prerelease.24 70 9/25/2026
2.0.0-prerelease.23 86 9/25/2026
2.0.0-prerelease.22 68 9/24/2026
2.0.0-prerelease.21 65 9/24/2026
2.0.0-prerelease.20 89 9/23/2026
2.0.0-prerelease.19 74 9/23/2026
2.0.0-prerelease.18 75 9/22/2026
Loading failed