Despro.Framework.Domain 2.0.8

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

Despro.Framework.Domain

The domain layer of Despro Framework.

Despro.Framework.Domain builds on Despro.Framework.Base and provides the domain-modeling building blocks and self-contained domain services: value objects, security primitives (hashing, password policy) and domain-specific validators. It has no dependency on infrastructure or presentation concerns.

  • Package: Despro.Framework.Domain
  • Version: 2.0.4
  • Target framework: net10.0
  • Depends on: Despro.Framework.Base

Installation

dotnet add package Despro.Framework.Domain

DI registration

using Despro.Framework.Domain;

builder.Services.AddFrameworkDomain(builder.Configuration);

AddFrameworkDomain binds the AuthPasswordOptions configuration section, validates its data annotations, and additionally enforces RequiredUniqueChars <= RequiredLength. Because validation runs with ValidateOnStart(), a misconfigured password policy fails the application at boot instead of at first use.


What's inside

Value objects (ValueObjects)

Type Description
ValueObject Abstract base implementing structural equality over public properties/fields via reflection. Members can be excluded with [IgnoreMember].
AuthPasswordOptions Password-policy options (RequiredLength 4–128, RequiredUniqueChars, RequireDigit/Lowercase/Uppercase/NonAlphanumeric). Bound from configuration section AuthPasswordOptions.
PasswordChecker Validates a password against AuthPasswordOptions (ValidatePassword extension and static Validate), throwing InvalidValueObjectException with localized messages on failure.
PasswordGenerator Generates policy-compliant passwords (Generate, CreateRandomPassword).
IranianNationalCodeChecker IsValid(nationalId) checksum validation for Iranian national codes.
TextHelper String utilities: ToSlug, Subscribe (truncate), ConvertHtmlToText, SetUnReadableEmail, GenerateCode, IsText, IsUniCode.

Security tools (SecurityTools)

  • Hasher — SHA-256 helpers: HashPassword(username, password), GetHash(text), GetHash(object) (property-aware object hashing).

Exceptions (DomainExceptions)

  • BaseDomainException (abstract, extends Base's BaseException).
  • InvalidValueObjectException — thrown by value-object/password validation failures.

Usage

// A value object with structural equality:
public sealed class Money : ValueObject
{
    public decimal Amount { get; }
    public string Currency { get; }
    public Money(decimal amount, string currency) => (Amount, Currency) = (amount, currency);
}

// Password policy (bound + validated by AddFrameworkDomain):
public class ChangePasswordHandler(IOptions<AuthPasswordOptions> options)
{
    public void Handle(string newPassword)
    {
        options.Value.ValidatePassword(newPassword); // throws InvalidValueObjectException if weak
        var suggestion = PasswordGenerator.Generate(options.Value);
        // ...
    }
}

Example configuration:

{
  "AuthPasswordOptions": {
    "RequiredLength": 8,
    "RequiredUniqueChars": 4,
    "RequireNonAlphanumeric": true,
    "RequireLowercase": true,
    "RequireUppercase": true,
    "RequireDigit": true
  }
}

Project structure

Despro.Framework.Domain
├── DomainExceptions/    # BaseDomainException, InvalidValueObjectException
├── SecurityTools/       # Hasher (SHA-256)
├── ValueObjects/        # ValueObject, TextHelper, IranianNationalCodeChecker, Password*
│   └── Auth/            # AuthPasswordOptions
└── FrameworkDomainDi.cs # AddFrameworkDomain
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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.8 96 9/8/2026
2.0.7 93 9/8/2026
2.0.6 124 7/18/2026
2.0.5 226 7/2/2026
2.0.4 120 7/2/2026