Purview.ZodSharp.AspNetCore 2.0.0-prerelease.10

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

Purview.ZodSharp.AspNetCore

NuGet version Release

ASP.NET Core integration for Purview.ZodSharp NuGet version. Convert failed validation results into standard ProblemDetails / HttpValidationProblemDetails payloads while preserving the structured validation issues.

Installation

dotnet add package Purview.ZodSharp.AspNetCore

Usage

using ZodSharp.AspNetCore;

var result = BasketSchema.Validate(basket);

if (!result.IsSuccess)
{
    var problem = result.ToHttpValidationProblemDetails();
    return Results.ValidationProblem(
        problem.Errors,
        extensions: new Dictionary<string, object?>
        {
            ["issues"] = problem.Extensions["issues"],
        });
}

ToHttpValidationProblemDetails() maps each ValidationError to a standard HttpValidationProblemDetails.Errors entry keyed by its JSON path. The structured ValidationIssue metadata (code, origin, minimum/maximum, inclusive bounds, path, message) is preserved in the issues extension so clients get more than a flat message list.

A ValidationProblemDetails overload is also available:

var problem = result.ToValidationProblemDetails();

Exception handling

Thrown ZodExceptions (e.g. from a value object's strict deserialization) are converted automatically by an IExceptionHandler:

builder.Services.AddZodSharpProblemDetails();

var app = builder.Build();
app.UseExceptionHandler();

Mapping error types to status codes

Register an ErrorType and map error codes to HTTP statuses and formatted messages:

public static class ConcurrentErrorType
{
    public static readonly ErrorType SaveFailed = new(
        Code: "aggregate_save_failed",
        Description: "The aggregate could not be saved.",
        HttpStatus: StatusCodes.Status409Conflict,
        MessageFormat: "Aggregate '{AggregateId}' (of type {AggregateType}) failed to save")
    {
        Parameters = ["AggregateId", "AggregateType"]
    };
}

ErrorTypeRegistry.Default.Register(ConcurrentErrorType.SaveFailed);

A ValidationError carrying parameters such as ["AggregateId"] = "agg-123" is then surfaced as a 409 Conflict response whose message reads Aggregate 'agg-123' (of type Invoice) failed to save. The analyzer ZODSASP001 (bundled with the package) warns when a MessageFormat placeholder is not declared in Parameters.

Documentation

License

MIT — see the package metadata in Purview.ZodSharp.AspNetCore 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. 
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.AspNetCore:

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.0.0-prerelease.21 0 9/24/2026
2.0.0-prerelease.20 53 9/23/2026
2.0.0-prerelease.19 47 9/23/2026
2.0.0-prerelease.18 39 9/22/2026
2.0.0-prerelease.17 39 9/22/2026
2.0.0-prerelease.16 47 9/21/2026
2.0.0-prerelease.15 45 9/21/2026
2.0.0-prerelease.14 47 9/21/2026
2.0.0-prerelease.13 46 9/20/2026
2.0.0-prerelease.12 56 9/20/2026
2.0.0-prerelease.11 47 9/19/2026
2.0.0-prerelease.10 50 9/19/2026
2.0.0-prerelease.9 61 9/18/2026
2.0.0-prerelease.8 42 9/17/2026
2.0.0-prerelease.7 56 9/17/2026
2.0.0-prerelease.6 98 9/14/2026
2.0.0-prerelease.5 72 9/12/2026
2.0.0-prerelease.4 58 9/12/2026
2.0.0-prerelease.3 94 9/8/2026
2.0.0-prerelease.2 69 9/6/2026
Loading failed