MasLazu.AspNet.Verification.Domain
1.0.0-preview.6
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
<PackageReference Include="MasLazu.AspNet.Verification.Domain" Version="1.0.0-preview.6" />
<PackageVersion Include="MasLazu.AspNet.Verification.Domain" Version="1.0.0-preview.6" />
<PackageReference Include="MasLazu.AspNet.Verification.Domain" />
paket add MasLazu.AspNet.Verification.Domain --version 1.0.0-preview.6
#r "nuget: MasLazu.AspNet.Verification.Domain, 1.0.0-preview.6"
#:package MasLazu.AspNet.Verification.Domain@1.0.0-preview.6
#addin nuget:?package=MasLazu.AspNet.Verification.Domain&version=1.0.0-preview.6&prerelease
#tool nuget:?package=MasLazu.AspNet.Verification.Domain&version=1.0.0-preview.6&prerelease
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 createdVerificationVerified- When a verification is successfully completedVerificationExpired- When a verification expiresVerificationFailed- 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.
๐ Related Documentation
- Abstraction Layer - Core contracts and interfaces
- Application Layer - Business logic and services
- Infrastructure Layer - Data access implementation
- API Layer - REST API endpoints
| Product | Versions 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. |
-
net9.0
- MasLazu.AspNet.Framework.Domain (>= 1.0.0-preview.15)
- MasLazu.AspNet.Verification.Abstraction (>= 1.0.0-preview.6)
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 |