Trellis.Core
3.0.0-alpha.520
See the version list below for details.
dotnet add package Trellis.Core --version 3.0.0-alpha.520
NuGet\Install-Package Trellis.Core -Version 3.0.0-alpha.520
<PackageReference Include="Trellis.Core" Version="3.0.0-alpha.520" />
<PackageVersion Include="Trellis.Core" Version="3.0.0-alpha.520" />
<PackageReference Include="Trellis.Core" />
paket add Trellis.Core --version 3.0.0-alpha.520
#r "nuget: Trellis.Core, 3.0.0-alpha.520"
#:package Trellis.Core@3.0.0-alpha.520
#addin nuget:?package=Trellis.Core&version=3.0.0-alpha.520&prerelease
#tool nuget:?package=Trellis.Core&version=3.0.0-alpha.520&prerelease
Trellis.Core
Railway-oriented error handling and domain foundations for .NET with Result<T>, Maybe<T>, typed errors, value-object bases, and DDD primitives.
Installation
dotnet add package Trellis.Core
Quick Example
using Trellis;
Result<string> email = Result.Ok("ada@example.com")
.Ensure(
value => value.Contains('@'),
_ => Error.InvalidInput.ForField(
ValidationCodes.StringEmail,
"email",
detail: "Email is invalid."))
.Map(value => value.Trim().ToLowerInvariant());
Key Features
- Compose explicit success and failure paths with
Bind,Map,Tap,Ensure,Combine, and their async variants. - Use static
Result.Ensure(condition, () => error)guards to create errors only on failure; predicate and async-predicate overloads support the same lazy factories. - Model expected absence with
Maybe<T>instead ofnullor exceptions. - Treat blank optional text as absent with
Maybe.OptionalNonBlank; nonblank input reaches the factory unchanged, whileMaybe.Optionalremains null-only. - Return a closed set of typed errors that adapters can map consistently.
- Accumulate failures with
EnsureAll, including lazy value-dependent error factories. - Validate collections with
TraverseAll((item, index) => ...)or sequentialTraverseAllAsync((item, index, ct) => ..., cancellationToken), retaining input positions while accumulating failures. - Compose nested validation paths with
InputPointer.AppendPropertyandAppendIndex, preserving location and RFC 6901 escaping. - Build aggregates, entities, value objects, specifications, domain events, and integration-event contracts.
- Define source-generated
Required*<TSelf>scalar value objects. - Validate cursor pagination with
PageRequest,CursorCodec,Page<T>, andPageBuilder. - Classify failures for retry-aware workers and consumers.
Result<T> is deliberately not directly JSON-serializable. At an HTTP boundary, map it with Trellis.Asp.ToHttpResponse(); elsewhere, unwrap it through Match or TryGetValue before serialization.
Generated Required*<TSelf> types are lenient by default: use [NotDefault] to reject sentinel values and [Trim] to normalize strings.
Error factories
Case-scoped factories put code first and optional detail last. Use Error.Conflict.For<Order>("order.already-shipped", id: orderId) for a resource conflict, or Error.NotFound.For<Order>(id: orderId) without inventing a reason code. ForField(code, field, args: ..., detail: ...) supports a property name or InputPointer; ForRule(code, fields: ..., args: ..., detail: ...) supports related fields.
Required codes reject null/empty/whitespace, including constructors and with assignments. Custom codes remain supported. NotFound and Gone retain optional codes and the unspecified sentinel. Explicit resources use ResourceRef. This is a breaking argument-order change: migrate positional string IDs and validation fields by meaning, not just until the code compiles.
Documentation
| 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.18.0)
NuGet packages (16)
Showing the top 5 NuGet packages that depend on Trellis.Core:
| Package | Downloads |
|---|---|
|
Trellis.Authorization
Lightweight authorization primitives for Trellis. Provides Actor, IActorProvider, IAuthorize, IAuthorizeResource of TResource, IResourceLoader, and ResourceLoaderById types that integrate with the Trellis Result type system. No dependency on any mediator or web framework. |
|
|
Trellis.Asp
ASP.NET Core integration for Trellis. Result-to-HTTP response mapping, rate-limit rejection handling, scalar value validation, JSON converters (with bundled AOT source generator), and ASP.NET actor providers (Claims, Entra, Easy Auth, Development) for Trellis.Authorization. |
|
|
Trellis.Mediator
Result-aware pipeline behaviors for martinothamar/Mediator. Provides validation, authorization, logging, tracing, and exception handling behaviors that understand Trellis Result types and short-circuit correctly. |
|
|
Trellis.Primitives
Infrastructure and ready-to-use implementations for primitive value objects in Domain-Driven Design. Includes base classes (RequiredString, RequiredGuid) with source generation, plus EmailAddress with RFC 5322 validation. Eliminates primitive obsession with strongly-typed domain primitives. |
|
|
Trellis.Testing
FluentAssertions extensions and test doubles for Trellis - assert Result, Maybe, and Error types with readable fluent syntax |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0-alpha.526 | 24 | 9/30/2026 |
| 3.0.0-alpha.524 | 114 | 9/27/2026 |
| 3.0.0-alpha.520 | 152 | 9/25/2026 |
| 3.0.0-alpha.516 | 266 | 9/22/2026 |
| 3.0.0-alpha.513 | 141 | 9/22/2026 |
| 3.0.0-alpha.505 | 272 | 9/13/2026 |
| 3.0.0-alpha.495 | 408 | 8/24/2026 |
| 3.0.0-alpha.458 | 365 | 8/19/2026 |
| 3.0.0-alpha.455 | 392 | 8/19/2026 |
| 3.0.0-alpha.449 | 204 | 8/18/2026 |
| 3.0.0-alpha.447 | 201 | 8/18/2026 |
| 3.0.0-alpha.432 | 240 | 7/6/2026 |
| 3.0.0-alpha.428 | 211 | 7/3/2026 |
| 3.0.0-alpha.425 | 244 | 6/27/2026 |
| 3.0.0-alpha.419 | 167 | 6/24/2026 |
| 3.0.0-alpha.418 | 335 | 6/23/2026 |
| 3.0.0-alpha.417 | 155 | 6/23/2026 |
| 3.0.0-alpha.397 | 239 | 6/18/2026 |
| 3.0.0-alpha.396 | 144 | 6/18/2026 |
| 3.0.0-alpha.394 | 161 | 6/18/2026 |