Trellis.Core 3.0.0-alpha.520

This is a prerelease version of Trellis.Core.
There is a newer prerelease version of this package available.
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
                    
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="Trellis.Core" Version="3.0.0-alpha.520" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Trellis.Core" Version="3.0.0-alpha.520" />
                    
Directory.Packages.props
<PackageReference Include="Trellis.Core" />
                    
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 Trellis.Core --version 3.0.0-alpha.520
                    
#r "nuget: Trellis.Core, 3.0.0-alpha.520"
                    
#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 Trellis.Core@3.0.0-alpha.520
                    
#: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=Trellis.Core&version=3.0.0-alpha.520&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Trellis.Core&version=3.0.0-alpha.520&prerelease
                    
Install as a Cake Tool

Trellis.Core

NuGet Package

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 of null or exceptions.
  • Treat blank optional text as absent with Maybe.OptionalNonBlank; nonblank input reaches the factory unchanged, while Maybe.Optional remains 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 sequential TraverseAllAsync((item, index, ct) => ..., cancellationToken), retaining input positions while accumulating failures.
  • Compose nested validation paths with InputPointer.AppendProperty and AppendIndex, 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>, and PageBuilder.
  • 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed