Purview.ZodSharp 2.0.0-prerelease.8

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

Purview.ZodSharp

NuGet version Release

A high-performance schema validation library for C#, ported from TypeScript Zod. It features zero-allocation validation, struct-based rules, a fluent API, and a compile-time source generator for maximum performance.

This package is the core library. It also ships the [ZodSchema] source generator and JSON Schema export (Z.ToJsonSchema). JSON Schema import (Z.FromJsonSchema) and JSON serialization integrations are available in the companion packages:

Installation

dotnet add package Purview.ZodSharp

Quick start

using ZodSharp;

var nameSchema = Z.String().Min(3).Max(50);
var result = nameSchema.Validate("John");

if (result.IsSuccess)
    Console.WriteLine($"Valid name: {result.Value}");

Composable schemas for objects, arrays, unions, discriminators, records, tuples and more:

var userSchema = Z.Object()
    .Field("name", Z.String().Min(1))
    .Field("age", Z.Number().Min(0).Max(120).Int())
    .Field("email", Z.String().Email())
    .Build();

Source generator

Mark a class, struct, or record with [ZodSchema] and a zero-allocation validator is generated at compile time:

using System.ComponentModel.DataAnnotations;
using ZodSharp;

[ZodSchema]
public class User
{
    [Required]
    [StringLength(50, MinimumLength = 3)]
    public string Name { get; set; } = string.Empty;

    [Range(0, 120)]
    public int Age { get; set; }

    [EmailAddress]
    public string? Email { get; set; }
}

var result = UserSchema.Validate(user);
var validated = UserSchema.Parse(user); // throws on failure

// Value-first composition methods (enable via EnableComposition, on by default):
var adult = UserSchema.ApplyRefine(user, u => u.Age >= 18, "Must be adult");

DataAnnotations attributes such as [Required], [Length], [StringLength], [MinLength], [MaxLength], [Range], [RegularExpression], [AllowedValues], [DeniedValues], [EmailAddress], and [Compare] are validated with direct, typed codegen (no reflection).

JSON Schema export

var jsonSchema = Z.ToJsonSchema(userSchema, new ToJsonSchemaOptions { Title = "User" });

Documentation

License

MIT — see the package metadata in Purview.ZodSharp 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 (6)

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

Package Downloads
Purview.ZodSharp.AspNetCore

ASP.NET Core ProblemDetails integration for ZodSharp validation results.

Purview.ZodSharp.SystemTextJson

A high-performance C# port of Zod schema validation library. Features zero-allocation validation, struct-based rules, fluent API, and source generator support for maximum performance.

Purview.ZodSharp.NewtonsoftJson

A high-performance C# port of Zod schema validation library. Features zero-allocation validation, struct-based rules, fluent API, and source generator support for maximum performance.

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.8 0 9/17/2026
2.0.0-prerelease.7 7 9/17/2026
2.0.0-prerelease.6 71 9/14/2026
2.0.0-prerelease.5 88 9/12/2026
2.0.0-prerelease.4 61 9/12/2026
2.0.0-prerelease.3 103 9/8/2026
2.0.0-prerelease.2 78 9/6/2026
2.0.0-prerelease.1 76 9/5/2026