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
<PackageReference Include="Despro.Framework.Domain" Version="2.0.8" />
<PackageVersion Include="Despro.Framework.Domain" Version="2.0.8" />
<PackageReference Include="Despro.Framework.Domain" />
paket add Despro.Framework.Domain --version 2.0.8
#r "nuget: Despro.Framework.Domain, 2.0.8"
#:package Despro.Framework.Domain@2.0.8
#addin nuget:?package=Despro.Framework.Domain&version=2.0.8
#tool nuget:?package=Despro.Framework.Domain&version=2.0.8
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, extendsBase'sBaseException).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 | 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
- Despro.Framework.Base (>= 2.1.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.