MartinDrozdik.DDD.Options 0.10.0

dotnet add package MartinDrozdik.DDD.Options --version 0.10.0
                    
NuGet\Install-Package MartinDrozdik.DDD.Options -Version 0.10.0
                    
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="MartinDrozdik.DDD.Options" Version="0.10.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MartinDrozdik.DDD.Options" Version="0.10.0" />
                    
Directory.Packages.props
<PackageReference Include="MartinDrozdik.DDD.Options" />
                    
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 MartinDrozdik.DDD.Options --version 0.10.0
                    
#r "nuget: MartinDrozdik.DDD.Options, 0.10.0"
                    
#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 MartinDrozdik.DDD.Options@0.10.0
                    
#: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=MartinDrozdik.DDD.Options&version=0.10.0
                    
Install as a Cake Addin
#tool nuget:?package=MartinDrozdik.DDD.Options&version=0.10.0
                    
Install as a Cake Tool

DDD Options - Configuration That Fails Fast

NuGet NuGet Downloads Build & Test .NET License

IOptions<T> with a section convention and FluentValidation, based on MartinDrozdik.DDD. No ASP.NET Core dependency, so your business layer can define and register its own options. Check the demo.

Installation

dotnet add package MartinDrozdik.DDD.Options

Also check this repos' DDD Claude Code plugin for better AI code generation.

Options

Leverages IOptions<T> with FluentValidation for configuration validation and automatic binding.

Configured to fail fast if your configuration is invalid. No more "wOrKs On My MaChInE".

public class InvoiceOptions : IValidatedAppOptions<InvoiceOptions>
{
    public static string Section => "App:Invoice"; // Simple binding from config (appsettings etc.)

    // FluentValidation validator, because attributes are for suckers
    public static AbstractValidator<InvoiceOptions> Validator { get; } = new OptionsValidator();

    // Your actual options properties:
    public required int StartingId { get; init; }
    public required string DefaultName { get; init; }
    
    private class OptionsValidator : AbstractValidator<InvoiceOptions>
    {
        public OptionsValidator()
        {
            RuleFor(e => e.StartingId).GreaterThanOrEqualTo(0);
            RuleFor(e => e.DefaultName).NotNull().NotEmpty();
        }
    }
}

// Register it:
builder.Services.AddValidatedAppOptions<InvoiceOptions>();

For simpler options without validation:

public class SimpleOptions : IAppOptions
{
    public static string Section => "App:Simple";
    public required string Value { get; init; }
}

builder.Services.AddAppOptions<SimpleOptions>();

Both bind strictly (ErrorOnUnknownConfiguration = true) and validate on start, so a typo in a config key is a startup failure rather than a silent default.

To read options during startup, before the container exists, go through the configuration manager:

var db = builder.Configuration.GetRequiredValidatedOptions<DatabaseOptions>();
// also: GetOptions<T>(), GetRequiredOptions<T>(), GetValidatedOptions<T>()

Testing

Goes well with MartinDrozdik.DDD.Testing smoke tests, since options are validated on startup.

public class DemoAppSmokeTests(ITestOutputHelper testOutputHelper)
    : WebApplicationSmokeTests<Program>(new DemoAppBuilder(testOutputHelper));
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 (1)

Showing the top 1 NuGet packages that depend on MartinDrozdik.DDD.Options:

Package Downloads
MartinDrozdik.DDD.Web

A library to support web domain-driven design development with solutions to common problems.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.10.0 43 9/15/2026
0.9.1 106 8/31/2026
0.9.0.1 122 8/8/2026
0.9.0 108 8/8/2026