feat(domain): WordCounterService + WordCountResult + ChargeableCharConfig entity + exceptions (PRC-001)
- WordCounterService: pure domain service, 7-step algorithm (null/empty fast path → length check → emoji detection via Rune.EnumerateRunes → count specials before replace → replace specials+hyphens → collapse whitespace → tokenize) - WordCountResult: sealed record with TotalWords + IReadOnlyDictionary<string,int> SpecialCharCounts - 4 domain exceptions extending DomainException: EmojiDetectedException, WordCountValidationException, ChargeableCharConfigInvalidException, ChargeableCharConfigForwardOnlyException - ChargeableCharConfig: rich entity with Create factory (invariants), Rehydrate reconstructor, ScheduleNewPrice (forward-only, returns new entity), Deactivate (idempotent) - ChargeableCharCategories: enum-as-string constants (Currency, Percentage, Exclamation, Question, Other) - DomainTimeProviderExtensions: internal GetArgentinaToday helper (mirrors Application.Common without creating Domain→Application dependency) - 60 new tests: 25 golden cases all GREEN, 12 entity invariant tests, 12 exception tests, 5 WordCountResult tests, 6 ChargeableCharConfig entity tests
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using SIGCM2.Domain.Exceptions;
|
||||
|
||||
namespace SIGCM2.Domain.Pricing.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// PRC-001 — Thrown when a ChargeableCharConfig value fails domain business validation
|
||||
/// (e.g., PricePerUnit ≤ 0, Symbol empty/too long, Category unknown, ValidFrom in the past).
|
||||
/// → HTTP 400
|
||||
/// Used as defense-in-depth alongside FluentValidation in the Application layer.
|
||||
/// </summary>
|
||||
public sealed class ChargeableCharConfigInvalidException : DomainException
|
||||
{
|
||||
public string Field { get; }
|
||||
public string Reason { get; }
|
||||
|
||||
public ChargeableCharConfigInvalidException(string field, string reason)
|
||||
: base($"Valor inválido para {field}: {reason}")
|
||||
{
|
||||
Field = field;
|
||||
Reason = reason;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user