Purview.ValueObjects 1.0.0-prerelease.4

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

Purview.ValueObjects

Source-generated scalar and complex value objects for .NET.

Adds F#-style single-case types to C#. Mark a partial struct or class with [Scalar] or [ValueObject] and the source generator produces Create/Hydrate factories, normalization (OnNormalize), validation (OnValidate), Empty instances, equality, comparison, implicit conversions, and JSON converters.

  • DTOs – strong types with serialization/deserialization and business rules.
  • Entity Framework – value objects map cleanly onto JSON columns via ScalarJsonConverterFactory.
  • Domain models – the F#-style single-case union pattern in C#.

Quick start

[Scalar]
public readonly partial record struct EmailAddress
{
    public string Value { get; }

    static partial void OnNormalize(ref string value) => value = value?.Trim().ToLowerInvariant()!;

    static partial void OnValidate(string value)
    {
        if (string.IsNullOrWhiteSpace(value))
            throw new ArgumentException("Email is required.", nameof(value));
    }
}

var email = EmailAddress.Create("Demo@Example.com");
// email.Value == "demo@example.com"

JSON serialization

Scalar value objects serialize as their underlying value. Register the converter factory on your JsonSerializerOptions:

var options = new JsonSerializerOptions();
options.Converters.Add(new ScalarJsonConverterFactory());

Use the same options for Entity Framework JSON columns:

modelBuilder
    .Entity<Customer>()
    .Property(c => c.Email)
    .HasColumnType("jsonb");

See the src/src/Sample and src/src/ZodSharpSample projects for end-to-end examples.

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.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (15)

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

Package Downloads
Purview.EventSourcing

Core abstractions, aggregate types, facades, transactions, and dependency injection extensions for building event-sourced .NET applications.

Purview.EventSourcing.SqlServer

Azure SQL and SQL Server event stream storage provider for Purview EventSourcing.

Purview.EventSourcing.AzureStorage

Azure Table Storage and Blob Storage event store provider for Purview EventSourcing, including snapshot and large-payload support.

Purview.EventSourcing.MongoDB

MongoDB event stream and snapshot storage provider for Purview EventSourcing.

Purview.EventSourcing.CosmosDb

Azure Cosmos DB queryable snapshot storage provider for Purview EventSourcing.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-prerelease.4 37 9/20/2026
1.0.0-prerelease.3 50 9/20/2026
1.0.0-prerelease.2 114 9/18/2026
1.0.0-prerelease.1 47 9/18/2026