Purview.Results.ZodSharp 1.0.0-prerelease.2

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

Purview.Results.ZodSharp

NuGet version Release

Bridges ZodSharp ValidationResult<T> values into Purview.Results, so validation outcomes flow through the same result pipeline as every other expected outcome instead of throwing.

Installation

dotnet add package Purview.Results.ZodSharp

Quick start

ZodSharp validation never throws: Validate returns a ValidationResult<T> carrying the validated value on success and every ValidationError on failure. ToResult translates that into a result whose error type the caller chooses:

return RepositoryReconciliationResultSchema
    .Validate(reconciliationResult)
    .ToResult<RepositoryReconciliationResult, ReconciliationError>(errors =>
        new ReconciliationResultInvalid(reconciliationResult, errors)
    );

When the surrounding method's success type differs from the validated type, produce the failure with the generated AsFailure<TValue>() helper instead, because the validated value is not the value the method succeeds with:

var validated = ProviderConnectionIdSchema.Validate(providerConnectionId);

if (!validated.IsSuccess)
    return new ProviderConnectionInvalid(providerConnectionId, validated.Errors)
        .AsFailure<RepositoryReconciliationResult>();

return await ReconcileCoreAsync(validated.Value, repositories, cancellationToken);

API

Member Purpose
ValidationResult<TValue>.ToResult<TValue, TError>(Func<ImmutableArray<ValidationError>, TError> onFailure) Success carries the validated value; failure carries the created error. onFailure runs only when validation failed, so a successful validation allocates no error
IValidationErrorCarrier Implemented by an error value that carries ZodSharp validation errors, so an HTTP layer can turn it into a validation problem without knowing the error type

The error type must be named explicitly when it is a union, as in ToResult<RepositoryReconciliationResult, ReconciliationError>(...), because a union case does not carry the union type that contains it.

A factory returning a result rather than an error is deliberately not offered: for a lambda returning Result<TValue, TError> the compiler prefers a Func<..., TError> parameter and would silently nest the results. Naming the error type explicitly keeps the intent unambiguous.

Examples

src/examples/Examples.Zod is a runnable console example that validates a [ZodSchema] TenantInput and turns the outcome into a Result<Tenant, TenantError>, with the rejection carrying its reported ValidationErrors.

dotnet run --project src/examples/Examples.Zod

The repository README lists the Basic, ASP.NET Core and ASP.NET Core + Zod examples too.

Package Purpose
Purview.Results.ZodSharp.AspNetCore Renders the validation errors an IValidationErrorCarrier error carries as HttpValidationProblemDetails

Agent skills

This package ships the purview-results-zodsharp-validation agent skill under .agents/. Repositories that import Purview.BuildSdk get it mirrored into their own .agents/ folder on the next restore or build, so AI agents working there receive the guidance automatically.

License

MIT — see LICENSE.md.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Purview.Results.ZodSharp:

Package Downloads
Purview.Results.ZodSharp.AspNetCore

Maps Purview result failures that carry ZodSharp validation errors onto ASP.NET Core HttpValidationProblemDetails responses.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-prerelease.2 49 9/30/2026
1.0.0-prerelease.1 43 9/30/2026