Purview.ValueObjects
1.0.0-prerelease.6
dotnet add package Purview.ValueObjects --version 1.0.0-prerelease.6
NuGet\Install-Package Purview.ValueObjects -Version 1.0.0-prerelease.6
<PackageReference Include="Purview.ValueObjects" Version="1.0.0-prerelease.6" />
<PackageVersion Include="Purview.ValueObjects" Version="1.0.0-prerelease.6" />
<PackageReference Include="Purview.ValueObjects" />
paket add Purview.ValueObjects --version 1.0.0-prerelease.6
#r "nuget: Purview.ValueObjects, 1.0.0-prerelease.6"
#:package Purview.ValueObjects@1.0.0-prerelease.6
#addin nuget:?package=Purview.ValueObjects&version=1.0.0-prerelease.6&prerelease
#tool nuget:?package=Purview.ValueObjects&version=1.0.0-prerelease.6&prerelease
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 – reference
Microsoft.EntityFrameworkCoreand the generator emits mapping members (value converters, comparers, complex-type mapping) plus aConfigureValueObjectsextension for automatic mapping. Queries use the value object type directly. - 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");
Entity Framework Core
When your project references Microsoft.EntityFrameworkCore, the generator emits an EF nested class per value
object (a ValueConverter/ValueComparer) and an assembly-level ConfigureValueObjects extension that maps
them automatically:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ConfigureValueObjects(); // generated into your project
}
Scalar value objects convert to their underlying primitive column; complex value objects map as EF Core complex
types (EF Core 8+) by default or JSON columns via [ValueObject(EFMapping = EntityFrameworkMapping.Json)]. Queries compare
the value object type directly — no .Value required — or the raw underlying value (c.Email == "...",
m.Id == guid). See docs/Entity-Framework.md for the full guide.
See the src/src/Sample and src/src/ZodSharpSample projects for end-to-end examples.
| Product | Versions 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. |
-
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.6 | 0 | 9/25/2026 |
| 1.0.0-prerelease.5 | 72 | 9/24/2026 |
| 1.0.0-prerelease.4 | 54 | 9/20/2026 |
| 1.0.0-prerelease.3 | 65 | 9/20/2026 |
| 1.0.0-prerelease.2 | 143 | 9/18/2026 |
| 1.0.0-prerelease.1 | 62 | 9/18/2026 |