Trellis.Primitives
3.0.0-alpha.418
dotnet add package Trellis.Primitives --version 3.0.0-alpha.418
NuGet\Install-Package Trellis.Primitives -Version 3.0.0-alpha.418
<PackageReference Include="Trellis.Primitives" Version="3.0.0-alpha.418" />
<PackageVersion Include="Trellis.Primitives" Version="3.0.0-alpha.418" />
<PackageReference Include="Trellis.Primitives" />
paket add Trellis.Primitives --version 3.0.0-alpha.418
#r "nuget: Trellis.Primitives, 3.0.0-alpha.418"
#:package Trellis.Primitives@3.0.0-alpha.418
#addin nuget:?package=Trellis.Primitives&version=3.0.0-alpha.418&prerelease
#tool nuget:?package=Trellis.Primitives&version=3.0.0-alpha.418&prerelease
Trellis.Primitives
Strongly typed value objects for .NET, with built-in primitives like EmailAddress and Money plus composite JSON conversion and tracing registration for primitive value objects.
Installation
dotnet add package Trellis.Primitives
The Required*<TSelf> and ScalarValueObject<TSelf, TUnderlying> base classes live in Trellis.Core. The source generator, generated primitive JSON converter, and primitive trace source are bundled inside the Trellis.Core package (transitively referenced by Trellis.Primitives) — no extra package is required.
Quick Example
using Trellis;
using Trellis.Primitives;
// TryCreate returns Result<T>; pattern-match before using the value.
var emailResult = EmailAddress.TryCreate("ada@example.com");
// Money.Create throws on invalid input; use TryCreate for user input.
var subtotal = Money.Create(12.34m, "USD");
var shipping = Money.Create(2.00m, "USD");
// Arithmetic on Money returns Result<Money> (currency-mismatch / overflow safe).
Result<Money> grandTotal = subtotal.Add(shipping);
// Define a custom value object — the source generator emits TryCreate, equality, JSON converters, etc.
// RequiredString rejects null/empty/whitespace and trims by default; RequiredGuid rejects Guid.Empty.
public sealed partial class CustomerEmail : RequiredString<CustomerEmail>;
public sealed partial class OrderId : RequiredGuid<OrderId>;
Key Features
- Ready-to-use value objects for common concepts such as email, URL, money, and percentages.
Trellis.Corebase classes likeRequiredString<CustomerEmail>andRequiredGuid<OrderId>for custom domain types.- Lenient-by-default generated validation (rejects
nullonly); opt into sentinel rejection with[NotDefault]and string trimming with[Trim]when domain strictness is required. - Validation and parsing rules that stay with the type instead of leaking into handlers and controllers.
Documentation
Part of Trellis
This package is part of the Trellis framework.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- OpenTelemetry.Api (>= 1.16.0)
- Trellis.Core (>= 3.0.0-alpha.418)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Trellis.Primitives:
| Package | Downloads |
|---|---|
|
Trellis.EntityFrameworkCore
EF Core integration for Trellis. Convention-based value converter registration for Trellis primitives, Result-returning SaveChanges wrappers, Maybe/Result query extensions, and provider-agnostic database exception classification. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0-alpha.418 | 44 | 6/23/2026 |
| 3.0.0-alpha.417 | 44 | 6/23/2026 |
| 3.0.0-alpha.397 | 115 | 6/18/2026 |
| 3.0.0-alpha.396 | 65 | 6/18/2026 |
| 3.0.0-alpha.394 | 84 | 6/18/2026 |
| 3.0.0-alpha.385 | 70 | 6/15/2026 |
| 3.0.0-alpha.382 | 72 | 6/12/2026 |
| 3.0.0-alpha.372 | 74 | 6/10/2026 |
| 3.0.0-alpha.360 | 106 | 6/7/2026 |
| 3.0.0-alpha.342 | 93 | 6/5/2026 |
| 3.0.0-alpha.337 | 69 | 6/3/2026 |
| 3.0.0-alpha.336 | 57 | 6/3/2026 |
| 3.0.0-alpha.304 | 76 | 5/29/2026 |
| 3.0.0-alpha.158 | 114 | 4/5/2026 |
| 3.0.0-alpha.157 | 70 | 4/4/2026 |
| 3.0.0-alpha.140 | 75 | 3/30/2026 |
| 3.0.0-alpha.137 | 83 | 3/27/2026 |
| 3.0.0-alpha.135 | 63 | 3/26/2026 |
| 3.0.0-alpha.127 | 78 | 3/23/2026 |
| 3.0.0-alpha.123 | 72 | 3/19/2026 |