Purview.ValueObjects
1.0.0-prerelease.2
See the version list below for details.
dotnet add package Purview.ValueObjects --version 1.0.0-prerelease.2
NuGet\Install-Package Purview.ValueObjects -Version 1.0.0-prerelease.2
<PackageReference Include="Purview.ValueObjects" Version="1.0.0-prerelease.2" />
<PackageVersion Include="Purview.ValueObjects" Version="1.0.0-prerelease.2" />
<PackageReference Include="Purview.ValueObjects" />
paket add Purview.ValueObjects --version 1.0.0-prerelease.2
#r "nuget: Purview.ValueObjects, 1.0.0-prerelease.2"
#:package Purview.ValueObjects@1.0.0-prerelease.2
#addin nuget:?package=Purview.ValueObjects&version=1.0.0-prerelease.2&prerelease
#tool nuget:?package=Purview.ValueObjects&version=1.0.0-prerelease.2&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 – 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 samples/ folder 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.4 | 44 | 9/20/2026 |
| 1.0.0-prerelease.3 | 57 | 9/20/2026 |
| 1.0.0-prerelease.2 | 129 | 9/18/2026 |
| 1.0.0-prerelease.1 | 55 | 9/18/2026 |