MasLazu.AspNet.Verification.Domain 1.0.0-preview.6

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

MasLazu.AspNet.Verification.Domain

The Domain layer of the MasLazu ASP.NET Verification system. This project contains the core business entities, domain logic, and domain services that represent the heart of the verification system.

๐Ÿ“‹ Overview

This is the domain layer that encapsulates the business logic and domain entities. It contains the core business rules, entities, value objects, and domain services that define the verification system's behavior.

๐Ÿ—๏ธ Architecture

This project represents the Domain Layer in Clean Architecture:

  • Entities: Core business entities with identity and state
  • Value Objects: Immutable objects that describe characteristics
  • Domain Services: Business logic that doesn't naturally fit in entities
  • Domain Events: Events that represent business occurrences
  • Specifications: Business rules and query specifications

๐Ÿ“ฆ Dependencies

Package References

  • MasLazu.AspNet.Framework.Domain - Base domain framework with common domain patterns

Project References

  • MasLazu.AspNet.Verification.Abstraction - Core abstractions and contracts

๐Ÿš€ Core Components

Entities

Verification

The main verification entity representing a verification request:

public class Verification : EntityBase
{
    public Guid UserId { get; private set; }
    public string VerificationCode { get; private set; }
    public VerificationPurpose Purpose { get; private set; }
    public VerificationStatus Status { get; private set; }
    public DateTimeOffset CreatedAt { get; private set; }
    public DateTimeOffset ExpiresAt { get; private set; }
    public int AttemptCount { get; private set; }
    public int MaxAttempts { get; private set; }

    // Domain methods for business logic
    public bool IsExpired() => DateTimeOffset.UtcNow > ExpiresAt;
    public bool CanAttempt() => AttemptCount < MaxAttempts && !IsExpired();
    public void RecordAttempt() => AttemptCount++;
    public void MarkAsVerified() => Status = VerificationStatus.Verified;
}
VerificationPurpose

Entity representing different verification purposes:

public class VerificationPurpose : EntityBase
{
    public string Name { get; private set; }
    public string DisplayName { get; private set; }
    public string Description { get; private set; }
    public TimeSpan DefaultExpiration { get; private set; }
    public int DefaultMaxAttempts { get; private set; }
    public bool IsActive { get; private set; }
}

Enums

VerificationStatus
public enum VerificationStatus
{
    Pending = 0,
    Verified = 1,
    Expired = 2,
    Failed = 3
}
VerificationChannel
public enum VerificationChannel
{
    Email = 0,
    Sms = 1
}

๐Ÿ”ง Usage

The domain layer is typically used by the application layer services. Here's an example of how the domain entities might be used:

// Create a new verification
var verification = new Verification(
    userId: userId,
    code: generatedCode,
    purpose: purpose,
    expiresAt: DateTimeOffset.UtcNow.AddMinutes(15),
    maxAttempts: 3
);

// Check if verification is valid
if (verification.CanAttempt() && !verification.IsExpired())
{
    verification.RecordAttempt();

    if (verification.VerificationCode == providedCode)
    {
        verification.MarkAsVerified();
        // Save changes...
    }
}

๐Ÿ“‹ Business Rules

The domain layer enforces the following business rules:

  • Verifications expire after a configurable time period
  • Users have limited attempts to verify codes
  • Once verified, a verification cannot be reused
  • Verification codes must be unique and cryptographically secure
  • Different purposes can have different expiration times and attempt limits

๐Ÿ”„ Domain Events

The domain layer publishes events for important business occurrences:

  • VerificationCreated - When a new verification is created
  • VerificationVerified - When a verification is successfully completed
  • VerificationExpired - When a verification expires
  • VerificationFailed - When verification attempts are exhausted

๐Ÿงช Testing

The domain layer is designed to be easily testable with pure unit tests, as it contains no external dependencies. Domain logic can be tested in isolation from infrastructure concerns.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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 (2)

Showing the top 2 NuGet packages that depend on MasLazu.AspNet.Verification.Domain:

Package Downloads
MasLazu.AspNet.Verification.EfCore

Entity Framework Core implementation for ASP.NET verification system providing data access layer.

MasLazu.AspNet.Verification

Application layer for ASP.NET verification system providing business logic and services.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.6 147 10/2/2025
1.0.0-preview.5 145 10/1/2025
1.0.0-preview.4 156 9/29/2025
1.0.0-preview.3 154 9/29/2025
1.0.0-preview.2 119 9/28/2025