Purview.Results.ZodSharp
1.0.0-prerelease.2
dotnet add package Purview.Results.ZodSharp --version 1.0.0-prerelease.2
NuGet\Install-Package Purview.Results.ZodSharp -Version 1.0.0-prerelease.2
<PackageReference Include="Purview.Results.ZodSharp" Version="1.0.0-prerelease.2" />
<PackageVersion Include="Purview.Results.ZodSharp" Version="1.0.0-prerelease.2" />
<PackageReference Include="Purview.Results.ZodSharp" />
paket add Purview.Results.ZodSharp --version 1.0.0-prerelease.2
#r "nuget: Purview.Results.ZodSharp, 1.0.0-prerelease.2"
#:package Purview.Results.ZodSharp@1.0.0-prerelease.2
#addin nuget:?package=Purview.Results.ZodSharp&version=1.0.0-prerelease.2&prerelease
#tool nuget:?package=Purview.Results.ZodSharp&version=1.0.0-prerelease.2&prerelease
Purview.Results.ZodSharp
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.
Related packages
| 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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Purview.Results (>= 1.0.0-prerelease.2)
- Purview.ZodSharp (>= 2.0.0)
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 |